Threading support is still very new so stay conservative at this point
and enable threading without the GIL. This requires users to protect
concurrent access of mutatable Python objects (eg lists) with locks at
the Python level (something you should probably do anyway). The
advantage is that there is less of a performance hit for non-threaded
code, because the VM does not need to constantly release/acquire the GIL.
In the future the GIL will be made more efficient. There is also room to
improve the efficiency of non-GIL code by not using mutex's if there is
only one thread active.
Due to the way modern compilers work (allocating space for stack vars once
at tha start of function, and deallocating once on exit from), using
intermediate stack buffer of big size caused blockage of 4K (PATH_MAX)
on stack for the entire duration of MicroPython execution.
This follows source code/header file organization similar to few other
objects, and intended to be used only is special cases, where efficiency/
simplicity matters.
Previously, if there was chain of allocated blocks ending with the last
block of heap, it wasn't included in number of 1/2-block or max block
size stats.
To start with, the critical scripts _boot.py and flashbdev.py are frozen
to improve performance and reduce RAM consumption.
Saves about 1000 bytes of heap RAM for a bare boot with filesystem.
The 16k FreeRTOS heap originally had all TCBs and stacks dynamically
allocated within it (plus semaphores and some other things). Now that
xTaskCreateStatic is used instead of xTaskCreate, the TCBs and stacks
are allocated statically and no longer use any of the FreeRTOS heap.
Therefore, the FreeRTOS stack can be shrunk by the amount that has been
made static. Furthermore, the TCBs and stack that are now static should
be placed in the .rtos_heaps section of RAM because this RAM is treated
specially by the bootloader (the bootloader executes from the first 16k
of RAM and loads the firmware into the section starting after the 16k).
After this patch the FreeRTOS heap (ucHeap) is 7200 bytes. The memory
available for the MicroPython heap is 54936 bytes (including GC overhead).
In VStartSimpleLinkSpawnTask we change xTaskCreate to xTaskCreateStatic
so that the task is created using statically allocated memory for the TCB
and stack.
This means that xTaskCreate function is no longer needed (the static
version is now used exclusively).
This function is no longer used. Having the .boot section attribute
meant that it was included in the firmware regargless of use. Without
this attribute the linker can remove the function.