summaryrefslogtreecommitdiff
path: root/include/uthread.h
AgeCommit message (Collapse)Author
2025-10-22uthreads: Make use of CONFIG_IS_ENABLED consistentlyTom Rini
We do not yet support UTHREADS in xPL phases. However, we have the need to dummy out certain functions so that xPL can build when full U-Boot has UTHREADS enabled. Update the few places that need to use CONFIG_IS_ENABLED so that we have the correct dummy in xPL. Signed-off-by: Tom Rini <[email protected]> Acked-by: Jerome Forissier <[email protected]>
2025-05-01uthread: doc: fix inline documentationJerome Forissier
Fix Sphinx warnings: $ make htmldocs [...] ./include/uthread.h:56: warning: cannot understand function prototype: 'enum uthread_mutex_state ' ./include/uthread.h:64: warning: cannot understand function prototype: 'struct uthread_mutex ' ./include/uthread.h:56: warning: cannot understand function prototype: 'enum uthread_mutex_state ' ./include/uthread.h:64: warning: cannot understand function prototype: 'struct uthread_mutex ' Signed-off-by: Jerome Forissier <[email protected]> Reported-by: Tom Rini <[email protected]> Tested-by: Heinrich Schuchardt <[email protected]> Acked-by: Ilias Apalodimas <[email protected]>
2025-04-23uthread: add uthread_mutexJerome Forissier
Add struct uthread_mutex and uthread_mutex_lock(), uthread_mutex_trylock(), uthread_mutex_unlock() to protect shared data structures from concurrent modifications. Signed-off-by: Jerome Forissier <[email protected]>
2025-04-23uthread: add cooperative multi-tasking interfaceJerome Forissier
Add a new internal API called uthread (Kconfig symbol: UTHREAD) which provides cooperative multi-tasking. The goal is to be able to improve the performance of some parts of U-Boot by overlapping lengthy operations, and also implement background jobs in the U-Boot shell. Each uthread has its own stack allocated on the heap. The default stack size is defined by the UTHREAD_STACK_SIZE symbol and is used when uthread_create() receives zero for the stack_sz argument. The implementation is based on context-switching via initjmp()/setjmp()/ longjmp() and is inspired from barebox threads [1]. A notion of thread group helps with dependencies, such as when a thread needs to block until a number of other threads have returned. The name "uthread" comes from "user-space threads" because the scheduling happens with no help from a higher privileged mode, contrary to more complex models where kernel threads are defined. But the 'u' may as well stand for 'U-Boot' since the bootloader may actually be running at any privilege level and the notion of user vs. kernel may not make much sense in this context. [1] https://github.com/barebox/barebox/blob/master/common/bthread.c Signed-off-by: Jerome Forissier <[email protected]> Reviewed-by: Ilias Apalodimas <[email protected]>