1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

1011 Commits

Author SHA1 Message Date
Marian Buschsieweke
2d2bb4b308
core/mutex: clean up
This restores a pre-existing design decision to implement both
blocking and non-blocking mutex locking with the same code. Those
implementations have been split prior to the introduction of
the `core_mutex_priority_inheritance` module when `mutex_trylock()`
indeed was trivial. This decision didn't age well, so undo it.
2022-09-29 13:12:33 +02:00
benpicco
4737d8148a
Merge pull request #17702 from benpicco/core/macros/math
core/macros: add math helper macros
2022-09-22 14:14:24 +02:00
Benjamin Valentin
c53051f72f core/macros: add math helper macros 2022-09-21 16:00:26 +02:00
Sören Tempel
80116651c2 core: Treat stack overflows as an unrecoverable error
Presently, RIOT just emits a warning when a stack overflow is
encountered but still resumes execution. In my view, execution should be
aborted as the detection of a stack overflows via the heuristic provided
by the scheduler is an unrecoverable error.

I ran into this while performing automated tests of a RIOT application
where a stack overflow occurred but I only noticed this after inspecting
the application output more closely.

Similar to SSP failures, I added crash_code for stack overflows.
2022-08-12 05:26:22 +02:00
c2a1afa12a
Merge pull request #18606 from jan-mo/fix/20220916__core_msg_queue_print_restore_irq
core/msg.c: irq was not restored properly
2022-09-17 03:45:39 +02:00
Jan Mohr
e0febd08e8 core/msg.c: irq was not restored properly 2022-09-16 15:56:17 +02:00
Gregory Holder
4d4c595185
core/mutex: fix typo in docs 2022-09-16 14:52:13 +02:00
Marian Buschsieweke
6790167a18
Merge pull request #18226 from benpicco/cpu_get_last_instruction
cpu: cpu_print_last_instruction() -> cpu_get_caller_pc()
2022-09-15 20:06:10 +02:00
Benjamin Valentin
7abaae7bbd treewide: fix typos 2022-09-15 12:12:23 +02:00
Benjamin Valentin
ea917f4b07 cpu: cpu_print_last_instruction() -> cpu_get_caller_pc() 2022-09-15 10:49:56 +02:00
Marian Buschsieweke
c07181c1c4
core/mutex: fix priority inheritance on AVR
This fixes https://github.com/RIOT-OS/RIOT/issues/18545 as the code
previously relied on `sched_change_priority()` not directly scheduling
a new thread while IRQs are disabled, but rather later when IRQs are
restored. This is true for Cortex-M MCUs (where the PendSV IRQ is used
to trigger the scheduler), but not e.g. for AVR.
2022-09-12 21:40:54 +02:00
Marian Buschsieweke
d53cd19142
core/sched.c: fix undefined behavior on 8-bit/16-bit
An `1 << x` with `x >= 15` is undefined behavior on 8-bit / 16-bit
machines (which typically have `sizeof(int) == 2`).

Using `1UL << x` is safe for `x <= 31`, which is large enough to make
use of the full 32 bits in `runqueue_bitcache`.

In addition, a `static_assert()` is added to enforce that
`SCHED_PRIO_LEVELS` is never set to anything larger than 32.
2022-09-09 21:55:17 +02:00
Marian Buschsieweke
8be03dc055
core: implement core_mutex_mitigate_priority_inversion 2022-08-05 13:08:52 +02:00
Benjamin Valentin
2e7d35f760 core/kernel_defines: drop CONST definition
This is not used anywhere in RIOT, but causes conflicts with external
library code.

So let's just get rid of this.
2022-06-16 15:26:27 +02:00
Benjamin Valentin
605f77f766 core/assert: print last instruction in assert() 2022-06-12 14:18:53 +02:00
chrysn
bdbde49753 bitarithm: Move extern const out of static inline functions
Workaround-For: https://github.com/immunant/c2rust/issues/423
2022-05-29 13:59:39 +02:00
ebdcccbd99
Merge pull request #16899 from kaspar030/queue_msg_thread_flags_yield_v2
core/msg: yield after thread_flags_wake() in queue_msg()
2022-05-06 19:04:19 +02:00
benpicco
b1715feb03
Merge pull request #17959 from benpicco/core-dummy
core: provide dummy implementation of thread and mutex for riotboot
2022-05-04 14:46:50 +02:00
Benjamin Valentin
8100203e95 core/thread, mutex: provide dummy implementation for riotboot
This is intended for the bootloader module where we don't enter thread
mode, so mutex must never attempt to switch context.

Instead use a simple busy wait that is enough to make the possible mutex
users (e.g. interrupt based SPI) in bootloader mode work.
2022-05-02 13:18:39 +02:00
Marian Buschsieweke
a405599986
core/xfa: Silence clangd warning
Use `uintptr_t` for arithmetic rather than `const char *` to fix the
following warning:

> comparePointers: Subtracting pointers that point to different objects
2022-04-26 22:15:00 +02:00
0c87335a45 core/msg: yield after thread_flags_wake() in queue_msg() 2022-04-21 17:28:41 +02:00
2ba85c1bc8 core: add support for test_utils_print_stack_usage
- activate THREAD_CREATE_STACKTEST also if test_utils_print_stack_usage
  is used

- make thread_measure_stack_free() available unconditionally

- if DEVELHELP is active, call test_utils_print_stack_usage() on any
  thread exit

- if DEVELHELP is active, call test_utils_print_stack_usage() after main
  for the idle thread, if that is used
2022-03-29 21:49:35 +02:00
Leandro Lanzieri
a7cc59d9f0
core/Kconfig: move MODULE_CORE_LIB symbol to fix menuconfig display 2022-03-18 08:23:46 +01:00
d248b2d785 core/lib: hide _XTSTR() from doxygen 2022-03-10 15:35:02 +01:00
003d64dd6c core/lib: add doxygen for LOG_* macros 2022-03-10 10:15:14 +01:00
ca4f1ec05b core/lib: add doxygen for BIT0 - BIT31 2022-03-10 10:03:14 +01:00
f94d72b7fe core: add core_lib to Kconfig 2022-03-09 21:43:05 +01:00
3db7c1150a core: split out library code
This commit splits core into it's scheduler/IPC part and into other code
that is either used or uses the scheduler, through defined APIs.
2022-03-09 21:43:05 +01:00
Martine Lenders
bb89334322
core: add functionality to check queue state of another thread 2022-03-03 16:50:34 +01:00
7c0ddbd1d8
Merge pull request #17472 from chrysn-pull-requests/doc-flags-msgs
core (largely doc): Differentiate message types from thread flags
2022-02-27 21:10:47 +01:00
chrysn
b923fec952 core/thread: Add constant value to check custom flags against
Co-authored-by: benpicco <benpicco@googlemail.com>
2022-02-26 22:17:33 +01:00
chrysn
4bbe0ec42d core/msg doc: No need for system-wide uniqueness 2022-02-26 22:08:31 +01:00
Benjamin Valentin
1bf151f01f core/init: declare board_init() 2022-02-25 15:08:58 +01:00
Karl Fessel
726c461cb5
Merge pull request #17574 from kfessel/p-fix-asserth
core/assert: avoid including panic.h with assert.h
2022-02-15 11:57:55 +01:00
Karl Fessel
ca112c224a core/assert.h: doxygen brief for __NORETURN 2022-02-15 10:34:54 +01:00
Karl Fessel
29caf39a9a core/panic.c: cleanup unneeded includes 2022-02-12 18:30:58 +01:00
Karl Fessel
0b52b3e62e core/assert: remove panic include from assert.h 2022-02-12 18:30:58 +01:00
benpicco
4aa90d3dc6
Merge pull request #16919 from maribu/core/rmutex
core/rmutex: use atomic utils
2022-02-04 11:56:05 +01:00
benpicco
5a57dec71a
Merge pull request #17093 from maribu/core/change_prio
core/sched: add sched_change_priority()
2022-01-28 20:01:20 +01:00
chrysn
fef782f735 core/thread doc: Point to helper function 2022-01-20 14:18:40 +01:00
chrysn
95b5052be4
Merge pull request #17502 from chrysn-pull-requests/queue-on-stack-never-quit
tests: Fix thread return with local message queue
2022-01-15 23:26:14 +01:00
Marian Buschsieweke
b6b7065ddc
core/rmutex: use atomic utils
Replace use of C11 atomics with atomic utils. This fixes

> error: address argument to atomic operation must be a pointer to a
>        trivially-copyable type ('_Atomic(int) *' invalid)

error when compiling on AVR with LLVM.
2022-01-14 09:52:17 +01:00
Marian Buschsieweke
d4e051596c
core/init: minor code cleanup 2022-01-12 16:15:48 +01:00
chrysn
b4a185132a core/msg: Document caution needed when having queue on the stack 2022-01-11 21:51:14 +01:00
5083061995
Merge pull request #17273 from maribu/core/IS_CT_CONSTANT
core: Add IS_CT_CONSTANT()
2022-01-08 00:21:07 +01:00
Marian Buschsieweke
68424a924c
core: Add IS_CT_CONSTANT()
This adds a simple macro to check (at C level) whether a given
expression is proven to be compile time constant and suitable for
constant folding. This allows writing code like this:

```C
int gpio_read(gpio_t pin) {
    if (IS_CT_CONSTANT(pin)) {
        /* this implementation should even be able to use the port and
         * pin number as immediate in inline assembly */
    }
    else {
        /* less efficient implementation that cannot use port and pin
         * number as immediate in inline assembly */
    }
}
```
2022-01-06 23:30:56 +01:00
8272e4fbd2
Merge pull request #17359 from benpicco/irq_is_in-bool
core: change return type of irq_is_in(), irq_is_enabled() to bool
2022-01-06 18:13:20 +01:00
chrysn
79e0e94312 core/thread doc: Contrast to messages 2022-01-05 19:33:51 +01:00
chrysn
5e7d65fc1f core/thread: Fix documentation
This has been wrong since 317b0133 when a third predefined flag was
removed.
2022-01-05 19:04:35 +01:00
Marian Buschsieweke
8608104fe5
core/kernel_defines.h: drop BUILD_BUG_ON()
This provides the same functionality as `static_assert()` provided by
C11 and has no advantages compared to it. Hence, encourage users to use
standard C functionality instead.
2022-01-05 15:41:39 +01:00
2b5ac8d422
Merge pull request #17262 from benpicco/msg_avail-return
core/msg: make msg_avail() return 0 on no queue
2022-01-05 14:13:28 +01:00
b84c3e47bf
Merge pull request #17267 from maribu/core/alignof
core/kernel_defines.h: drop ALIGN_OF()
2022-01-05 14:10:00 +01:00
chrysn
49ff487ea2 core: Warn about using irq_enable 2021-12-21 18:03:55 +01:00
Vitor Batista
921fdd0975 core/include/debug.h: minor debug fix 2021-12-08 17:09:17 +01:00
Benjamin Valentin
41a5b7ef7a core: change return type of irq_is_in(), irq_is_enabled() to bool
This only cleans up the API, no change in behavior or users of the API
is expected.
2021-12-08 15:53:15 +01:00
Marian Buschsieweke
b9c07f9622
core/sched: silence -Wcast-align 2021-12-03 10:12:34 +01:00
Benjamin Valentin
b5ea78ad47 core/msg: make msg_avail() return 0 on no queue
For the caller there should be no difference if there is no message
in the queue and if there can't be a message in the queue.

The current API works as one would expect if there is a message queue,
but once called from a thread that does not have a message queue
configured, code that does

    while (msg_avail())

will end up in an infinite loop.

Remove this foot-gun from the API by making the return value of
msg_avail() independend of the availability of a message queue.
2021-11-29 12:04:16 +01:00
Marian Buschsieweke
9535447e6f
core/kernel_defines.h: drop ALIGN_OF()
Since we moved to C11 now for all platforms, using `alignof()` provided
by `<stdalign.h>` has become the better option.
2021-11-25 09:20:22 +01:00
Jan Romann
3c86b74dc6
core: uncrustify 2021-11-18 15:44:00 +01:00
Marian Buschsieweke
d7a0ea1eec
core/bitarthm: suppress false positives
Co-authored-by: chrysn <chrysn@fsfe.org>
2021-11-18 09:45:22 +01:00
Marian Buschsieweke
58e197098d
core: add WITHOUT_PEDANTIC() and DECLARE_CONSTANT()
`WITHOUT_PEDANTIC(expr)` disables `-Wpedantic` for `expr`, but switches
back to the previous diagnostic settings afterwards. This helps defining
macros that are not strictly ISO compliant without having to drop the
`-Wpedantic` flag entirely.

`DECLARE_CONSTANT(identifier, const_expr)` declares an anonymous `enum`
constant named `identifier` and assigns it the value `const_expr`. Here,
`const_expr` has to be a compile time constant, but is not needed to be
an integer constant expression. It basically is a tool to magically
convert a non-integer constant expression into a integer constant
expression.
2021-11-10 15:22:47 +01:00
Benjamin Valentin
e2639cb53a core/include/kernel_defines.h: Fix index_of()
Calculate the size of the element based on the array given, not based
on the element pointer.

The element might as well be given as a `void *` via a callback.
In that case, if the user forgets to cast the `void *` to the array
element type, the calculation returns false values.

Disarm this foot gun by basing the element size off the given array.
2021-11-06 00:35:39 +01:00
Benjamin Valentin
01a49d3d19 core/include/kernel_defines.h: add index_of() macro 2021-11-05 16:42:38 +01:00
Martine Lenders
e27fd3018e
core/thread.h: fix new uncrustify error 2021-11-05 09:27:00 +01:00
Martine Lenders
f08989a3c8
core: make SCHED_TEST_STACK boolean and default to 1 with DEVELHELP 2021-11-05 09:27:00 +01:00
Hauke Petersen
3d7d797a57
core/sched: add sched_change_priority() function
Co-authored-by: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
2021-11-02 20:44:32 +01:00
Marian Buschsieweke
ff7e7c26cf
core/log: Add anchor to doc to allow stable references 2021-10-10 21:35:31 +02:00
Martine Lenders
ea8e632eda
Merge pull request #16765 from benpicco/RIOT_VERSION_CODE
build system: add machine-readable RIOT_VERSION_CODE macro
2021-09-22 12:47:35 +02:00
Benjamin Valentin
7ef2594327 core/include/kernel_defines.h: add RIOT_VERSION_NUM macro 2021-09-21 17:43:29 +02:00
4fd1ae89a7
Merge pull request #16463 from kfessel/p-sched-int
core/sched: add runq_callback hook and runq inspection functions
2021-09-15 15:43:50 +03:00
2b2c5fe746 core/thread: provide getters for thread_t fields as used by ps() 2021-09-15 10:16:45 +02:00
chrysn
137399c8cb core/msg doc: Clarify; elaborating on interaction with queue 2021-09-01 14:56:41 +02:00
Hauke Petersen
b526394d82 core/irq.h: add irq_is_enabled() function 2021-08-25 08:01:05 +02:00
Jan Romann
4384795cb9
treewide: Remove excessive newlines 2021-08-13 19:50:38 +02:00
Karl Fessel
671a7edca1 core/sched: uncrustify sched_cb declaration
this is a change out of this PR scope to reduce
the number of uncrustify complains for future edits
2021-08-09 14:22:07 +02:00
Karl Fessel
3508012942 core/sched: name inspection functions the same as the used clist fns 2021-08-09 14:18:18 +02:00
Francisco
d7b3328601
Merge pull request #16098 from kfessel/p-remove-lifo
core/lifo: Remove lifo [after 2021.04]
2021-06-15 13:55:30 +02:00
JulianHolzwarth
8309889e39 core/msg.c: fixed msg_queue_print() 2021-06-02 01:28:22 +02:00
Karl Fessel
9f00528a58 core/sched: add runq_callback hook and runq inspection functions 2021-05-10 15:01:58 +02:00
95a2456457
Merge pull request #16330 from kfessel/p-add-clist-special
core/clist: add special cardinality tests and matching unittest
2021-04-15 12:14:58 +02:00
Karl Fessel
5735d99971 core/clist: add special cardinality tests and matching unittest
adds clist_exactly_one() and clist_more_than_one()
and a unittest that tests them
2021-04-14 21:00:10 +02:00
Karl Fessel
1dde0f42d4 core/sched: keep scheduler clist internal to sched
adds sched_runq_advance(prio)
used it in core/thread and
test malloc_thread_safety
2021-04-14 09:53:04 +02:00
020945a773 core/clist: add clist_is_empty() 2021-04-09 10:54:29 +02:00
Joakim Nohlgård
87727febd7 core/msg: Fix mismatched printf bool format
_Bool will be extended to int when calling the variadic printf function.
2021-03-24 12:01:23 +01:00
Joakim Nohlgård
783c407787 core/msg: Fix mismatched printf signed/unsigned format
enum signedness depends on the platform settings, use explicit casts for robustness
2021-03-24 12:01:18 +01:00
Joakim Nohlgård
a83516b2f6 core/msg: Fix mismatched printf signed/unsigned format
cib_avail returns unsigned int
2021-03-24 12:01:07 +01:00
e8e8405c4a core/thread: move thread configuration into seperate header 2021-03-02 11:56:11 +01:00
Karl Fessel
1c1f051ab7 core/lifo: Remove lifo 2021-02-27 11:59:36 +01:00
Karl Fessel
55a0ca402b core/lifo: deprecate file for remove after 2021.04 2021-02-27 10:17:33 +01:00
Karl Fessel
9ab0681634 core/lifo: remove lifo.c, keep api with lifo.h
use LOG_DEBUG instead of DEBUG
2021-02-26 17:45:31 +01:00
2861d1f353 core/xfa: typeof() -> __typeof__() 2021-02-23 13:37:19 +01:00
df4dc36d91 core/xfa: add "experimental" note 2021-02-18 10:46:08 +01:00
d310044a88 core/xfa: fix doxygen issues 2021-02-18 10:46:08 +01:00
249ed5f2e1 core/include/xfa.h: uncrustify 2021-02-18 10:46:08 +01:00
2bc7bb4740 core/xfa: make externc happy 2021-02-18 10:46:08 +01:00
e827f0bdf1 core/xfa: add comments explaining the pragmas 2021-02-18 10:46:08 +01:00
50dc68bd21 core/xfa: make const XFA's volatile
This prevents gcc from figuring out that an XFA that has been
initialized in the same file is technically empty when the compilation
unit is seen by itself. This happened with gcc 10.1.0 on msp430-elf.
2021-02-18 10:46:08 +01:00
b54afa1449 xfa: remove duplicate "const" from _XFA_CONST 2021-02-18 10:46:08 +01:00
ac549abbb9 xfa: remove common -Txfa.ld include 2021-02-18 10:46:08 +01:00
bdd59ae7f2 core: disable -Warray-bounds for XFA users 2021-02-18 10:46:08 +01:00