移植C $ C $ç它使用fork()的到Android

编程入门 行业动态 更新时间:2024-10-23 22:36:55
本文介绍了移植C $ C $ç它使用fork()的到Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我已经用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?

感谢您。

推荐答案

从女神的消息:

markmail/message/ruqp2t6gvhnhv654

所以你最好把它关闭。它可以忌讳的话题完全可以与过程管理。并没有什么作为行为不端的失控机进程吸吮处理器周期和电池汁更糟。更好的解决办法是几款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

本文发布于:2023-10-09 06:19:47,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1474939.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:fork   Android

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!