2011-01-17 06:28:32 Issues due to lack of MMU?
Gilles Ganault (FRANCE)
I'm a self-taught developper and would like to make sure I understand what the issues are when deploying an appliance based on non-MMU CPUs like the Blackfin running uClinux:
1. An application can access any address in RAM, this will occur silently with no segfault.
=> Is there a way to sandbox applications, or at least, be notified that it tried accessing some part of RAM that was already used by another application?
2. If the application hasn't been rewritten to run on a non-MMU CPU and makes extensive use of malloc() instead of grabbing a big chunck of memory at start time and handling memory itself, the RAM will become increasingly fragmented as the application runs, and at some point, any call to malloc() will fail even though the required RAM is available in the absolute but is just too fragmented.
=> If an offending application is stopped and restarted, will uClinux reclaim the RAM that application used? If not, is rebooting the appliance the only solution to reclaim RAM?
=> Is there a way to keep an eye on RAM, and stop/restart an application that is causing RAM fragmentation?
3. When porting an application to a non-MMU CPU + uClinux, are there tools available to scan its source code and spot issues that might not be caught by the compiler (eg. use of fork() won't compile, but extensive use of malloc() will pass muster, etc.)?
... and any other issue I should know about?
Thank you for any help.
2011-01-17 13:48:34 Re: Issues due to lack of MMU?
Mike Frysinger (UNITED STATES)
(1) this basic premise is semi-incorrect. apps do not get access to NULL pointers, nor processor MMRs, nor can they access memory that does not exist. all of these will trigger an error and the app will be killed.
if you want protection from the apps accessing each other's memory, then use the MPU.
(2) it depends on the memory patterns. *large* allocations will most likely fail after the system has been running.
of course the kernel reclaims all resources allocated by the app when it exits.
you can watch an application's /proc/<pid>/map file, but i dont see that being useful.
(3) simply compile the application. if a func is missing, you'll get a build failure.
2011-01-17 17:34:46 Re: Issues due to lack of MMU?
Gilles Ganault (FRANCE)
> If you want protection from the apps accessing each other's memory, then use the MPU.
Thanks Mike. I found a bit of information about the MPU:
> of course the kernel reclaims all resources allocated by the app when it exits. you can watch an application's /proc/ /map file, but i dont see that being useful.
I'll write a cron job to check use of RAM, and stop/restart rogue applications.