1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-25 14:33:52 +01:00

Merge pull request #16006 from chrysn-pull-requests/no-mutex-in-init

core/mutex: Check against mutex use outside of threads
This commit is contained in:
chrysn 2021-02-15 10:39:30 +01:00 committed by GitHub
commit 54b2436daa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 2 deletions

View File

@ -49,7 +49,9 @@ static inline __attribute__((always_inline)) void _block(mutex_t *mutex,
unsigned irq_state)
{
thread_t *me = thread_get_active();
/* Fail visibly even if a blocking action is called from somewhere where
* it's subtly not allowed, eg. board_init */
assert(me != NULL);
DEBUG("PID[%" PRIkernel_pid "] mutex_lock() Adding node to mutex queue: "
"prio: %" PRIu32 "\n", thread_getpid(), (uint32_t)me->priority);
sched_set_status(me, STATUS_MUTEX_BLOCKED);

View File

@ -60,7 +60,9 @@ somewhere else then they must be added to the include path. In
Board initialization functions are defined in `board.c`. This file must at
least define a `board_init()` function that is called at startup. This
function initializes the `CPU` by calling`cpu_init()` among others.
function initializes the `CPU` by calling`cpu_init()` among others. It is run
before the scheduler is started, so it must not block (e.g. by performing I2C
operations).
```c
void board_init(void)