问题描述
我已经用C写的,我正在移植使用NDK为Android的应用程序。这使得应用程序使用fork()定期创建子进程来执行一些任务。这些子进程与主进程通过管道后,他们的任务就完成了交流,然后退出。数据通过管道传送的量可以是数百千字节
I have written an application in C which I am porting to Android using the NDK. This application makes use of fork() to create child processes periodically to perform some tasks. These child processes communicate with the main process through pipes and then exit after their task is complete. The amount of data transferred through pipes can be hundreds of kilobytes.
我试图保持父进程在内存和CPU消耗方面非常瘦,也很稳定,但孩子的过程有时会占用资源量显著。这并不重要,如果孩子的过程有时是由系统终止缘于此。父进程可以很好地处理这些条件。
I'm attempting to keep the parent process very lean in terms of memory and CPU consumption and also very stable, but the child processes can sometimes take up a significant amount of resources. It doesn't matter much if the child processes are sometimes killed by the system due to this. The parent process can gracefully handle these conditions.
有关这个用例,它是精细保持叉()■在本地code?有没有通过Android的框架,这样做的更好的办法?
For this use case, is it fine to keep the fork()s in the native code? Is there a better way of doing this through Android's framework?
感谢您。
推荐答案
从女神的消息:
所以你最好把它关闭。它可以忌讳的话题完全可以与过程管理。并没有什么作为行为不端的失控机进程吸吮处理器周期和电池汁更糟。更好的解决办法是几款Android抽象,如在同一进程中传递的数据服务和广播接收器由静态类的手段或射击意图各地
So you better leave it off. It could open a full can of worms with process management. And there is nothing worse as misbehaving runaway native process sucking processor cycles and battery juice. Better solution would be several android abstractions like services and broadcast receivers in same process passing data around by means of static classes or firing intents
这篇关于移植C $ C $ç它使用fork()的到Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!