What's the point of using Busybox in a low ram embedded system

后端 未结 2 451
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-14 05:55

I\'m working on bringing linux to a custom Cortex-M7 board with 16 Mb of SDRAM and 64 Mb of Flash. The platform has no-MMU, no shared libraries, FLAT executables.

I\

2条回答
  •  Happy的楠姐
    2021-01-14 06:41

    The point of BusyBox is that you need to have only one (shared) executable in memory.

    You wrote:

    It turns out that everytime one of these commands are executed the system needs to load the FULL, one and only busybox executable (650 Kb on my system).

    That's not entirely true. For the first command the executable is loaded in memory indeed. But if you're running multiple commands (i.e. multiple BusyBox instances), the executable is not loaded into memory multiple times. A large part of the binary (simply said: all read-only data, such as the executable code and constant data) will be reused. Each additional process only requires some additional memory for its own tasks.

    So if a single instance of BusyBox consumes 640 kB of memory, it's possible that 10 instances together only use 1 MB of memory, while 10 unique executables of 200 kB would use 2 MB.

    I would recommend to do some realistic tests on your system and check the actual memory consumption. But note that tools such as ps or top can be a bit misleading or difficult to understand. A lot has been written about that already, and if you would like to know more about that, a good starting point would be here.

提交回复
热议问题