Tbox added 64K microkernel compilation mode

2016/12/05 08:13
Reading number 350

In order to further tailor tbox and better adapt to the embedded development platform, tbox has added --micro=y Micromodule compilation options for

If this compilation option is enabled, only some lightweight modules in the tbox will be compiled. Yes, the size of the compiled library should be about 64K.

First, let's talk about some compilation options related to the library size:

 *'-- smallest=y': general platform, minimum compilation mode, all third-party dependent libraries will be disabled, all extension modules will be disabled, and minimal compilation optimization will be enabled (internal libraries will also save memory as much as possible) *'-- micro=y': specially designed for embedded platforms, only compiles the lightest modules, and enables minimal compilation optimization (some optional components may be included)

The difference between smallest and micro is that even if smallest is enabled and all extension modules are disabled, more common components are built in for daily basic development than micro, while micro is specially designed for embedded platforms. The built-in default components are more streamlined, and some weight level modules are not put in

Therefore, if you want to compile the minimum tbox library, you only need to execute the following configuration:

 $ xmake f --micro=y  $ xmake

If you want to enable coroutine support under micro, you only need to:

 $ xmake f --micro=y --coroutine=y $ xmake

Compilation is enough. Generally, the library size will be controlled at about 64K. At present, there are not many built-in modules. Later, it will be further streamlined and optimized to include more modules in 64K.

At present, some modules supported by the microkernel compilation mode are:

  • The stackless thread library (lighter than the stackfull version, each coroutine only occupies dozens of bytes, and the switching efficiency is also improved 5-6 times. It only takes 40 ms to switch 1000w times on the Macosx)
  • Lightweight libc library api support (support some of the longest used interfaces)
  • support list_entry / single_list_entry Single double chain container (ratio list / single_list More lightweight, external, no object memory maintenance)
  • Original socket interface operation
  • File operation related api
  • DNS address resolution, ipv4, ipv6 and other operation interfaces
  • Bits data operation and parsing
  • Provide system memory and continuous static memory allocator (you can specify that all memory in the tbox is allocated in one continuous space, which is applicable to scenarios with strict requirements on memory resources)
  • Supports memory out of bounds and leak detection
  • Thread related basic interface
  • Provide single instance and atomic operation interface
  • Spinlock support
  • Cross platform __tb_thread_local__ Thread local storage support
  • Trace print interface
  • Iterator support (currently only used for list_entry / single_list_entry

For a list of more support modules for micro compilation, see micro.lua

In the future, more lightweight modules will be added (such as timers, more containers and algorithm support) while keeping the library size unchanged


Personal homepage: TBOOX open source project

Expand to read the full text
Loading
Click to lead the topic 📣 Post and join the discussion 🔥
Reward
zero comment
zero Collection
zero fabulous
 Back to top
Top