mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-15 01:23:49 +01:00
sys/event: manage event thread size via build system
This adds a mechanism for modules to declare requirements on the thread stack size in their `Makefile.dep` and let the build system then override the default stack size, if any requirements are declared. The motivation is to allow multiple modules to have special requirements without causing conflicts, as just adding the following to their `Makefile.include` would do: ```Makefile CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE=<MAGIC_NUMBER> ``` Instead, the new mechanism would work by having them both declare in their `Makefile.dep`: ```Makefile EVENT_THREAD_MEDIUM_STACKSIZE_MIN += ``` The build system then picks the maximum number in `EVENT_THREAD_MEDIUM_STACKSIZE_MIN` and exposes this as stack size, if any module did declare a minimum requirement. Co-authored-by: benpicco <benpicco@googlemail.com>
This commit is contained in:
parent
c6450c702d
commit
f0540a9000
@ -212,3 +212,7 @@ endif
|
||||
ifneq (,$(filter unicoap,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/net/application_layer/unicoap/Makefile.include
|
||||
endif
|
||||
|
||||
ifneq (,$(filter event,$(USEMODULE)))
|
||||
include $(RIOTBASE)/sys/event/Makefile.include
|
||||
endif
|
||||
|
||||
35
sys/event/Makefile.include
Normal file
35
sys/event/Makefile.include
Normal file
@ -0,0 +1,35 @@
|
||||
include $(RIOTMAKE)/utils/strings.mk
|
||||
|
||||
# This applies to all thread stacks
|
||||
ifneq (, $(EVENT_THREAD_STACKSIZE_MIN))
|
||||
EVENT_THREAD_STACKSIZE_MIN := $(call max_number,$(EVENT_THREAD_STACKSIZE_MIN))
|
||||
endif
|
||||
|
||||
ifeq (,$(filter event_thread_highest, $(USEMODULE)))
|
||||
# No highest priority event thread, so the highest prio queue is handled by
|
||||
# the same thread handling the medium priority queue. So we "trickle down"
|
||||
# the requirements here
|
||||
EVENT_THREAD_MEDIUM_STACKSIZE_MIN += $(EVENT_THREAD_HIGHEST_STACKSIZE_MIN)
|
||||
else
|
||||
ifneq (, $(EVENT_THREAD_HIGHEST_STACKSIZE_MIN))
|
||||
EVENT_THREAD_HIGHEST_STACKSIZE_MIN := $(call max_number,$(EVENT_THREAD_HIGHEST_STACKSIZE_MIN) $(EVENT_THREAD_STACKSIZE_MIN))
|
||||
CFLAGS += -DEVENT_THREAD_HIGHEST_STACKSIZE=$(EVENT_THREAD_HIGHEST_STACKSIZE_MIN)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (,$(filter event_thread_medium, $(USEMODULE)))
|
||||
# No medium priority event thread, so the medium prio queue is handled by
|
||||
# the same thread handling the lowest priority queue. So we "trickle down"
|
||||
# the requirements here
|
||||
EVENT_THREAD_LOWEST_STACKSIZE_MIN += $(EVENT_THREAD_MEDIUM_STACKSIZE_MIN)
|
||||
else
|
||||
ifneq (, $(EVENT_THREAD_MEDIUM_STACKSIZE_MIN))
|
||||
EVENT_THREAD_MEDIUM_STACKSIZE_MIN := $(call max_number,$(EVENT_THREAD_MEDIUM_STACKSIZE_MIN) $(EVENT_THREAD_STACKSIZE_MIN))
|
||||
CFLAGS += -DEVENT_THREAD_MEDIUM_STACKSIZE=$(EVENT_THREAD_MEDIUM_STACKSIZE_MIN)
|
||||
endif
|
||||
endif
|
||||
|
||||
ifneq (, $(EVENT_THREAD_LOWEST_STACKSIZE_MIN))
|
||||
EVENT_THREAD_LOWEST_STACKSIZE_MIN := $(call max_number,$(EVENT_THREAD_LOWEST_STACKSIZE_MIN) $(EVENT_THREAD_STACKSIZE_MIN))
|
||||
CFLAGS += -DEVENT_THREAD_LOWEST_STACKSIZE=$(EVENT_THREAD_LOWEST_STACKSIZE_MIN)
|
||||
endif
|
||||
@ -44,6 +44,32 @@
|
||||
* event queue gets its own thread. So higher priority events will always
|
||||
* preempt events of lower priority in this case.
|
||||
*
|
||||
* Managing Stack Size Requirements
|
||||
* --------------------------------
|
||||
*
|
||||
* A module using the medium priority event queue might require a certain
|
||||
* minimum stack size, say 1024, to operate correctly. Instead of just adding
|
||||
* `CFLAGS += -DDEVENT_THREAD_MEDIUM_STACKSIZE=1024`, it can instead add the
|
||||
* following to its `Makefile.dep`:
|
||||
*
|
||||
* ```Makefile
|
||||
* EVENT_THREAD_MEDIUM_STACKSIZE_MIN += 1024
|
||||
* ```
|
||||
*
|
||||
* In the `Makefile.include` of `sys/event` the highest value of the minimum
|
||||
* requirements declared by any module will be picked and added to the
|
||||
* `CFLAGS`.
|
||||
*
|
||||
* @note `EVENT_THREAD_MEDIUM_STACKSIZE_MIN` and
|
||||
* `EVENT_THREAD_HIGHEST_STACKSIZE_MIN` always apply to the thread
|
||||
* managing the medium priority queue.
|
||||
* @details E.g. without the module `event_thread_medium` the lowest priority
|
||||
* and medium priority queues are both handled by the lowest priority
|
||||
* even thread. In that case, `EVENT_THREAD_MEDIUM_STACKSIZE_MIN` would
|
||||
* ensure a minimum thread statck size on the lowest priority even
|
||||
* thread. With `event_thread_medium` in use, it would instead apply
|
||||
* to the stack of the dedicated medium event queue thread.
|
||||
*
|
||||
* @{
|
||||
*
|
||||
* @file
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user