[kernel] Dynamically allocate task array from bootopts #1839
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This enhancement allows the previously fixed maximum number of ELKS processes to be set in /bootopts, thus allowing for more tasks (sometimes useful in networking), or less (useful for systems with very small amounts of memory).
The default value is still 16. The task structure used to be contained in the kernel data segment, which subtracted from the available heap space used for other resources. It is now allocated from the kernel heap; with each task structure using 876 bytes, they are an expensive resource - 14016 bytes used. (More on PC-98 as its BIOS requires a larger stack size when performing disk I/O).
meminfo
now shows the total task allocation bytes as a "TASK" entry so that memory usage can be seen.The implementation turned out a bit tricky, as the crt0.S startup code used to set the startup SP to the idle task's stack space. The kernel startup now uses the kernel interrupt stack for a temp stack, then switches stacks to the idle task after the /bootopts file has been read and the task array allocated.