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

1061 Commits

Author SHA1 Message Date
66092f5506 core: Introduce cross file arrays (XFA)
Co-Authored-By: Joakim Nohlgård <joakim.nohlgard@eistec.se>
2021-02-16 14:21:32 +01:00
chrysn
6145949f88 core/mutex: Add assert guard against usage without threads 2021-02-15 06:01:01 +01:00
Martine Lenders
9b40bb63c2
core: apply uncrustify patches 2021-02-02 22:21:14 +01:00
9d5f87bf67
core/thread: Allow for inline thread_yield_higher
Similar to irq.h, this allows for inline the often trivial
thread_yield_higher function
2021-01-19 11:03:20 +01:00
f0ce992d4a
core/thread: uncrustify header file 2021-01-19 10:28:58 +01:00
323fa3b5ac
core/mutex: fix typo in documentation 2020-12-29 11:48:48 +01:00
Marian Buschsieweke
8bbe56c302
core/mutex: compatibility with non-C languages
Due to limited compatibility with C, we cannot use the inline mutex_trylock
implementation for C++. Instead, we provide a mutex_trylock_ffi() intended for
foreign function interfaces. This should also benefit rust users.
2020-12-09 11:53:48 +01:00
Marian Buschsieweke
472d6d0abc
core/mutex: fix documentation 2020-12-08 23:04:16 +01:00
229291ef01
Merge pull request #15442 from maribu/mutex_abort
core/mutex: Add mutex_cancel
2020-12-08 17:12:52 +01:00
Marian Buschsieweke
df66dd0272
core/mutex: uncrustify 2020-12-08 14:50:50 +01:00
Marian Buschsieweke
e348407888
core/mutex: Add mutex_cancel() & mutex_lock_cancelable()
Add a version of `mutex_lock()` that can be canceled with the obvious name
`mutex_lock_cancelable()`. This function returns `0` on success, and
`-ECANCELED` when the calling thread was unblocked via a call to
`mutex_cancel()` (and hence without obtaining the mutex).

This is intended to simplify the implementation of `xtimer_mutex_lock_timeout()`
and to implement `ztimer_mutex_lock_timeout()`.
2020-12-08 14:50:49 +01:00
benpicco
aabd5eaca5
Merge pull request #15506 from kaspar030/refactor_thread_info
core: refactor thread info
2020-11-26 13:01:09 +01:00
ceea0ba949 core/thread: add thread_is_active() 2020-11-25 20:49:00 +01:00
1d5e2e9cd9 all: remove traces of kernel_types.h
Automatically removed using:

    $ git grep -l kernel_types | xargs sed -i '/^#include .kernel_types/d'
2020-11-25 17:52:34 +01:00
017e9e9d4d core/thread: add thread_get_status() 2020-11-25 14:39:22 +01:00
5321bcde89 core: thread: move thread_state_to_string() from ps.c 2020-11-25 14:35:00 +01:00
65f997026f core: drop kernel_types.h 2020-11-25 13:18:53 +01:00
1711b4b649 core/include/kernel_types.h: re-add c++ compat parts 2020-11-23 17:13:35 +01:00
0b801c4de0 all: adapt to moved sched defines 2020-11-23 16:56:34 +01:00
7fa8b69912 core: include inttypes.h in sched.h
sched.h now defines PRIkernel_pid to PRIi16, which in turn is defined in
inttypes.h.
2020-11-23 16:56:34 +01:00
1ca0c23173 core/msg: adapt to changed thread define location 2020-11-23 16:56:34 +01:00
369e9b30e2 core: move scheduler defines to sched.h 2020-11-23 16:56:34 +01:00
91111555a6 core/mbox: add mbox_size() and mbox_avail() 2020-11-20 10:38:17 +01:00
Marian Buschsieweke
a06a7978d3
core/mutex: clean up mutex_lock()
- Split out handling of the blocking code path of mutex_lock() into a static
  `_block()` function. This improves readability a bit and will ease review of
  a follow up PR.
- Return `void` instead of `int`.
2020-11-18 11:58:49 +01:00
Marian Buschsieweke
90103f2a6a
core/mutex: consistent debug output 2020-11-18 09:13:00 +01:00
c4ef8b71e1
Merge pull request #15327 from maribu/mutex_cleanup_splitout
core/mutex: Cleanup
2020-11-13 18:37:27 +01:00
Benjamin Valentin
eea2df99a3 core/msg_bus: enhace documentation 2020-11-09 21:13:08 +01:00
Marian Buschsieweke
d760e931ae
core/mutex: Cleanup
- Use static inline function for `mutex_try_lock()`
    - The implementation is trivial enough with the inline-able IRQ API to just
      always be inline-ed
- Rename `_mutex_lock()` to `mutex_lock()` and drop the blocking parameter
    - This was possible to the stand-alone `mutex_try_lock()` implementation
    - This yields a measurable performance bump
2020-11-06 23:27:13 +01:00
benpicco
f7d9e2f1ab
Merge pull request #15398 from maribu/mutex-doc
core/mutex: improve documentation
2020-11-06 19:15:10 +01:00
Marian Buschsieweke
876d500846
core/mutex: improve documentation 2020-11-06 18:23:26 +01:00
Leandro Lanzieri
1e41c6453a
core/sched_cb: add module to Kconfig 2020-11-06 15:57:56 +01:00
Martine Lenders
dd81a070f0
Merge pull request #15365 from miri64/core/enh/debug-IS_ACTIVE
core: debug: remove parenthesis around ENABLE_DEBUG define
2020-11-03 17:49:14 +01:00
benpicco
ee7a52db2f
Merge pull request #14023 from benpicco/core/msg_bus-bus_flag
core/msg_bus: allow to differ between messages form bus and from thread
2020-11-03 13:51:19 +01:00
Martine Lenders
2df29a6806
core: debug: remove parenthesis around ENABLE_DEBUG define 2020-11-03 13:01:08 +01:00
Benjamin Valentin
d6a6c218a3 core/msg_bus: allow to differ between messages form bus and from thread
Currently it is not possible to check if a message was sent over a bus
or if it was send the usual way using `msg_send()`.

This adds a flag to the `sender_pid` if the message was sent over a bus.
`MAXTHREADS` is currently set to 32, so there is still plenty of room in
the PID space. (`kernel_pid_t` is `int16_t`)

The message type for bus message type is already accessed through a getter
function, so it's just consistent to do the same for sender_pid.
2020-11-03 10:52:43 +01:00
Bas Stottelaar
cc2e6b08d1 core/*: ENABLE_DEBUG not needed for inttypes.h 2020-11-02 21:49:39 +01:00
Bas Stottelaar
2d3d047fd6 core/*: replace #if ENABLE_DEBUG with IS_ACTIVE 2020-11-02 21:34:12 +01:00
Bas Stottelaar
e675b6379e core/*: realign ENABLE_DEBUG 2020-10-23 00:45:56 +02:00
Bas Stottelaar
ff53307599 core/*: reorder ENABLE_DEBUG after last include 2020-10-23 00:41:18 +02:00
benpicco
c979fda1f3
Merge pull request #14367 from basilfx/feature/cortex_m33
cpu/cortex: add initial support for Cortex-M33
2020-10-08 22:55:06 +02:00
Bas Stottelaar
0f8cecb50b cpu/cortexm_common: add support for Cortex-M33 2020-10-06 17:11:26 +02:00
c59349482a
core/msg_bus: fix typo 'busses' -> 'buses'
Also fix typo 'seach' -> 'search'
2020-10-02 07:52:18 +02:00
benpicco
ab15d67e80
Merge pull request #15059 from maribu/core-thread-cast-align
core/thread.c: Silence -Wcast-align flase positives
2020-09-26 16:31:58 +02:00
Marian Buschsieweke
e028f6bbe6
core/thread: thread_measure_stack_free() const arg
Add `const` to stack pointer passed to thread_measure_stack_free()
2020-09-25 14:30:33 +02:00
Marian Buschsieweke
59321065db
core/thread.c: Silence -Wcast-align flase positives
Verified that each warning generated by -Wcast-align is indeed a false positive
and used an (intermediate) cast to `uintptr_t` to silence the warnings.
2020-09-22 15:15:28 +02:00
Marian Buschsieweke
85e506e893
core/include/kernel_defines.h: Fix container_of()
container_of() is safe to use in regard to alignment requirements, when used
correctly. Using `uintptr_t` instead of `char *` for applying the offset results
in -Wcast-align not complaining.
2020-09-22 15:13:03 +02:00
Francisco
64f6b7ffa4
Merge pull request #14702 from maribu/sched_active_thread
treewide: Fix direct access to scheduler internals
2020-09-21 09:09:59 +02:00
Jim O'Brien
bd149e7db9 thread: Add THREAD_NAMES make flag
Separate thread names from DEVELHELP so thread names can be
enabled in non-development/debug builds when required/desired.
THREAD_NAMES will be enabled by default then DEVELHELP is set to 1.
2020-09-10 10:08:27 +02:00
Marian Buschsieweke
2d8bdf9b83
core/sched: Drop declaration of sched_active_{pid,thread}
This should increase odds that developers use thread_get_active() and
thread_getpid() instead.
2020-09-07 12:59:55 +02:00
77735e7e10
Merge pull request #14709 from bergzand/pr/sched/return_thread 2020-09-03 10:18:47 +02:00
495644adc0
sched: return the new thread on sched_run 2020-09-02 13:32:14 +02:00
f68f19a73f
Merge pull request #14722 from bergzand/pr/sched/runqueue_clz
sched: Reverse runqueue order when CLZ is available
2020-09-01 22:57:30 +02:00
Cenk Gündoğan
538155c344
Merge pull request #14904 from leandrolanzieri/pr/kconfig/change_prefix_convention
treewide: modify Kconfig symbol prefixes
2020-09-01 15:57:06 +02:00
c83b78a567
Merge pull request #14762 from maribu/move_byteorder
core/byteorder: Moved to sys
2020-09-01 15:02:11 +02:00
Vincent Dupont
96b018d8dd core/panic: callback app during panic 2020-08-31 16:45:13 +02:00
Leandro Lanzieri
2e79e00ca7
treewide: change Kconfig prefix for module symbols
This changes the prefix used for the symbols that reprensent modules
(not the ones generated from USEMODULE).

MOD_ => MODULE_
2020-08-31 09:57:28 +02:00
dd45eaa472
sched: simplify MODULE_CORE_IDLE_THREAD conditional 2020-08-25 14:00:01 +02:00
764b3102e4
sched: Early exit when scheduling same thread after sleep 2020-08-25 13:59:58 +02:00
benpicco
f3e1032f6e
Merge pull request #14827 from keith-packard/pr/libc/picolibc
Pr/libc/picolibc
2020-08-24 18:06:56 +02:00
Keith Packard
531050ada2 picolibc: Enable TLS support [v4]
Allocate and initialize a thread-local block for each thread at the
top of the stack.

Set the tls base when switching to a new thread.

Add tdata/tbss linker instructions to cortex_m and risc-v scripts.

Signed-off-by: Keith Packard <keithp@keithp.com>

---

v2:
	Squash fixes

v3:
	Replace tabs with spaces

v4:
	Add tbss to fe310 linker script
2020-08-24 08:26:16 -07:00
Marian Buschsieweke
8745d820ba
core/thread_flags: Fix code indention
Apply coding convention on the indent in the single switch statement within
core.
2020-08-23 21:18:10 +02:00
e6fd3630eb
sched: Remove extra mpu_enable during context switch 2020-08-19 20:13:28 +02:00
Marian Buschsieweke
164d2ac8f2
core/byteoder: Moved to sys
The byteorder utilities are never used in `core`, but extensively in `sys`.
They seem to be better located in `sys`.
2020-08-14 16:28:59 +02:00
Marian Buschsieweke
81d40d3f66
core/byteorder: Add byteoder_htobebufll & inverse
- Add `byteorder_bebuftohll()` to read an 64 bit value from a big endian buffer
- Add `byteorder_htobebufll()` to write an 64 bit value into a big endian buffer
2020-08-14 13:36:40 +02:00
Leandro Lanzieri
f5e57fbca4
core: Add modules to Kconfig 2020-08-12 12:22:35 +02:00
ab1d0b6f98
sched: Reverse runqueue order when CLZ is available
This commit reverses the runqueue_cache bit order when the architecture
has a CLZ (count leading zeros) instruction. When the architecture
supports CLZ, it is faster to determine the most significant set bit of
a word than to determine the least significant bit set. Unfortunately
when the instruction is not available, it is more efficient to determine
the least significant bit set.

Reversing the bit order shaves off another 4 cycles on the same54-xpro.
From 147 to 143 ticks when testing with tests/bench_sched_nop.
Architectures where no CLZ instruction is available are not affected.
2020-08-06 20:39:14 +02:00
Marian Buschsieweke
13575b2131
core/thread_flags: Avoid using inline w/o static
Apparently clang doesn't like static variables / functions being accessed called
from inline function (-Wstatic-in-inline). This commit results in the same
binary being generated while making clang happy.
2020-08-06 17:54:32 +02:00
Marian Buschsieweke
57264c5059
core: Access internal vars via helper funcs
Replace accesses to `sched_active_thread`, `sched_active_pid`, and
`sched_threads` with `thread_get_active()`, `thread_get_active_pid()`, and
`thread_get_unchecked()` where sensible.
2020-08-06 16:47:33 +02:00
Marian Buschsieweke
4a31578982
core/thread: Add/change helper access functions
- Add `thread_get_active()` to access the TCB
- Add `thread_get_unchecked()` as fast alternative to `thread_get()`
- Drop `volatile` qualifier in `thread_get()`
    - Right now every caller of this function does this. It is better to
      contain this undefined behavior to at least one place in code
2020-08-06 14:35:43 +02:00
e81d0050d1
Merge pull request #14717 from kaspar030/optim_msg_active_thread
core/msg: sched_threads[sched_active_pid] -> sched_active_thread
2020-08-06 14:18:17 +02:00
5dbcfa3391
Merge pull request #14698 from benpicco/core/bitarithm-msb_clz
core/bitarithm: use __builtin_clz() for bitarithm_msb()
2020-08-06 13:00:34 +02:00
1bb3d56bd5 core/msg: sched_threads[sched_active_pid] -> sched_active_thread
Same result, but only a single volatile read.
2020-08-06 12:46:26 +02:00
c9883cebfd core/atomic_c11: fix I2 typedef for 16bit platforms 2020-08-05 14:32:57 +02:00
Marian Buschsieweke
315cdcdb5f
core/thread: Make thread_get inlineable 2020-08-05 10:51:16 +02:00
Benjamin Valentin
14144030fa core/bitarithm: use __builtin_clz() for bitarithm_msb()
The `clz` instruction pretty much implements getting the most significant bit
in hardware, so use it instead of the software implementation.

This reults in both a reduction in code size as in a speedup:

master:

  text    data     bss     dec     hex filename
 14816     136    2424   17376    43e0 tests/bitarithm_timings/bin/same54-xpro/tests_bitarithm_timings.elf

 + bitarithm_msb: 3529411 iterations per second

this patch:

  text    data     bss     dec     hex filename
 14768     136    2424   17328    43b0 tests/bitarithm_timings/bin/same54-xpro/tests_bitarithm_timings.elf

 + bitarithm_msb: 9230761 iterations per second
2020-08-04 17:50:09 +02:00
benpicco
2d4d29367e
Merge pull request #14642 from maribu/fix-byteorder-big-endian
core/byteorder: Fix be byte buffer conversion on big endian systems
2020-07-29 01:25:03 +02:00
Marian Buschsieweke
e4387c84fd
core/byteorder: Fix from/to be buffers on be
Big endian buffers on big endian systems are already in big endian byte order,
so no byte shuffling is needed. However, byte buffers might be unaligned, so
copy operations that are safe with unaligned memory accesses need to be
used.
2020-07-28 22:34:25 +02:00
Martine Lenders
b1bf8ab981
Merge pull request #14565 from bergzand/pr/sched/fix_retrigger
sched: Prevent retriggering the scheduler interrupt during idle sleep
2020-07-28 22:11:25 +02:00
Leandro Lanzieri
72d6d9047f
Merge pull request #14429 from benpicco/core/boot_msg
core/init: make boot message configurable
2020-07-28 16:40:08 +02:00
Benjamin Valentin
25e67e019e core/init: make boot message configurable
It can be desirable to not have the boot message printed each time
(e.g. logs are transferred over a wireless link on battery) while
still retaining the ability to receive INFO level logs.

This adds the option to disable the boot-up message (and also to customize
it if that is desireable).
2020-07-28 11:04:55 +02:00
benpicco
6ef4276c35
Merge pull request #14621 from benpicco/core/byteorder-be
core/byteorder: add Big Endian implementations
2020-07-28 10:30:27 +02:00
d59233baf1
Merge pull request #14556 from benpicco/bitarithm_test_and_clear
core/bitarithm: add bitarithm_test_and_clear()
2020-07-28 10:11:47 +02:00
Benjamin Valentin
df18bfb459 core/byteorder: add Big Endian implementations 2020-07-27 18:36:07 +02:00
Benjamin Valentin
4d34cee72f core: add comments to symbols used by OpenOCD
OpenOCD makes assumptions about those symbol names / enum entries,
so add a note about it as a comment.
2020-07-27 16:14:42 +02:00
Benjamin Valentin
46b89eb723 core/msg_bus: fix shift on 8-bit platforms
The previous shift would wrap if the compiler defaults to 16 bit words.
Use explicit `unsigned long` integer constants to mitigate that.

before:

2020-07-22 15:25:17,063 # THREAD 1 start
2020-07-22 15:25:17,063 # THREAD 2 start
2020-07-22 15:25:17,065 # THREAD 3 start
2020-07-22 15:25:17,066 # THREADS CREATED
2020-07-22 15:25:17,068 # Posted event 22 to 0 threads
2020-07-22 15:25:17,071 # Posted event 23 to 0 threads
2020-07-22 15:25:17,076 # Posted event 24 to 0 threads
2020-07-22 15:25:17,076 # SUCCESS
2020-07-22 15:26:00,188 # Exiting Pyterm

after:

2020-07-22 15:26:10,374 # THREAD 1 start
2020-07-22 15:26:10,374 # THREAD 2 start
2020-07-22 15:26:10,377 # THREAD 3 start
2020-07-22 15:26:10,377 # THREADS CREATED
2020-07-22 15:26:10,380 # Posted event 22 to 0 threads
2020-07-22 15:26:10,383 # T1 recv: Hello Threads! (type=23)
2020-07-22 15:26:10,386 # T3 recv: Hello Threads! (type=23)
2020-07-22 15:26:10,388 # Posted event 23 to 2 threads
2020-07-22 15:26:10,391 # T2 recv: Hello Threads! (type=24)
2020-07-22 15:26:10,394 # Posted event 24 to 1 threads
2020-07-22 15:26:10,396 # SUCCESS
2020-07-22 15:27:31 +02:00
Benjamin Valentin
a8904edd7d core/bitarithm: add bitarithm_test_and_clear() 2020-07-21 16:03:59 +02:00
2d74651237
sched: Clear context_switch_request after potential idle sleep
An interrupt serviced during the idle sleep can re-request a context
switch while the scheduler is already going to switch contexts after the
idle sleep. Thi sched_context_switch_request should thus be cleared
after the idle sleep and not before where it could be modified during
the idle sleep and get out of sync.
2020-07-21 11:27:08 +02:00
e1b810b613
core/sched: tiny logic optimization in idle case
In the case that the no_thread_idle feature is active, the
runqueue_bitcache is checked twice in the case no thread is available to
schedule. This changes the inner while loop to a do-while loop to save
one check from the initial loop iteration, saving a cycle or so in the
idle case.
2020-07-20 23:26:47 +02:00
benpicco
e2e51ae7ef
Merge pull request #14368 from jia200x/pr/byteorder_bebuftohs
core/byteorder: add uint32 from/to buffer funcs
2020-07-13 12:31:43 +02:00
Jose Alamos
244d5191c8 core/byteorder: add uint32 from/to buffer funcs 2020-07-13 11:21:30 +02:00
Benjamin Valentin
b71fde68e9 core/panic: launch USB bootloader for easy recovery
If a board was flashed via USB bootloader, a crash means the user has to
perform a procedure to manually enter the bootloader again for recovery.

To allow for easier recovery, automatically lauch the bootloader on crash
if `DEVELHELP` is enabled.
2020-07-01 20:36:59 +02:00
d199865a12 core: sched: correctly unschedule when there's no idle thread 2020-06-25 16:02:29 +02:00
e3f6c0f340 core: make idle thread optional 2020-06-25 16:02:28 +02:00
c4b4e66422
sched_cb: Add function documentation 2020-06-23 15:40:57 +02:00
Martine Lenders
379d113af7
Merge pull request #14076 from miri64/cib/doc/fix-max-size
core/cib: fix documented maximum size restrictions
2020-06-19 17:18:20 +02:00
Martine S. Lenders
c2e1b8afea
core/cib: fix documented maximum size restrictions
MAXINT is not a defined value and since the types are unsigned also
misleading.
2020-06-19 15:08:58 +02:00
benpicco
7ea26cb118
Merge pull request #14295 from benpicco/core/include/macros/units_convenience
core/include: don't use 64 bit for MHZ & MiB macros
2020-06-17 15:01:44 +02:00
Benjamin Valentin
0862a3c512 core/include: Don't use 64 bit for MHZ & MiB macros
Those macros are all about convenience. However, always using 64 bit makes casts
nececcary that goes against the idea of having a convenience macro.

E.g. when printing a frequency in KHZ one might want to do

	printf("freq: %lu kHz\n", freq / KHZ(1));

leads to an error

> error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'long long unsigned int'

Now we would have to cast - `%llu` is not available with newlib-nano and wholly
uneccecary.

Only use 64 bit artithmetic where necessary (GHZ, GiB), not for smaller units.
2020-06-17 12:50:50 +02:00
Leandro Lanzieri
4d65bc8e0a
cpu: Rename CPU_ARCH to CPU_CORE 2020-06-16 12:05:40 +02:00
Benjamin Valentin
8e83584f1c core/include: add macros for common units
I got tired of counting zeros in frequency defines, so add a few
helper macros to make defining frequency and sizes easier.
2020-06-03 16:00:19 +02:00
Benjamin Valentin
c29f133a63 core/msg_bus: clarify API of msg_bus_post()
Receiving threads must not modify the contents of the message as this
is racy by definition.

Also make `msg_bus_post()` accept `const void*` instead of `char *`.
2020-05-20 10:44:11 +02:00
Francisco Molina
cb5cbe7431
cpu/cortexm_common: add inlined header only def for irq_%
irq_% are not inlined by the compiler which leads to it branching
to a function that actually implement a single machine instruction.

Inlining these functions makes the call more efficient as well as
saving some bytes in ROM.
2020-05-12 16:37:34 +02:00
Benjamin Valentin
b3eb59c30e core/msg: add message bus 2020-04-28 13:35:05 +02:00
Benjamin Valentin
866c37c6b0 core/msg: split msg_send_int() into helper function
So it can be re-used for the message bus.
2020-04-28 11:30:56 +02:00
Francisco Molina
57938de035
core/doc: fix alignment 2020-04-21 15:10:56 +02:00
Francisco Molina
cbcb882454
core/include: add xtstr macro 2020-04-21 15:10:55 +02:00
46b6a95309
Merge pull request #13671 from jia200x/pr/move_thread_flags_error
core/thread_flags: remove #error from header file
2020-03-31 15:48:41 +02:00
8efe5960aa core: uncrustify 2020-03-30 17:02:08 +02:00
f99bc894de core: make some formatting uncrustify friendly (or ignore) 2020-03-30 17:00:32 +02:00
4a31068d15 core: disable uncrustify for atomic_*.c 2020-03-30 17:00:32 +02:00
JulianHolzwarth
dd6e51b1eb core/mutex.c _mutex_lock uses an int pointer
_mutex_lock uses a volatile int pointer for the parameter blocking instead of an int.
2020-03-26 17:26:07 +01:00
benpicco
a3dca87a78
Merge pull request #13300 from JulianHolzwarth/pr/thread_status_t/zombie_fixup
core/thread.c: thread_zombify small fix
2020-03-23 20:53:00 +01:00
Jose Alamos
027a47e3a8 core/thread_flags: remove #error from header file
This commit removes the #error from the thread_flags header.
This #error makes the usage of
if(IS_USED(MODULE_THAT_DEPENDS_ON_THREAD_FLAGS)) pattern harder,
because the error is triggered each time the header is included.
If a module uses any thread_flags function it will fail in link time
anyway.
2020-03-20 16:59:34 +01:00
Sören Tempel
59676a1f5e Make sure the mpu_noexec_ram regions has the lowest priority
From the ARMv7-M ARM section B3.5.3:

	Where there is an overlap between two regions, the register with
	the highest region number takes priority.

We want to make sure the mpu_noexec_ram region has the lowest
priority to allow the mpu_stack_guard region to overwrite the first N
bytes of it.

This change fixes using mpu_noexec_ram and mpu_stack_guard together.
2020-03-10 11:16:22 +01:00
1b8ec38e34 core/panic: add PANIC_EXPECT_FAIL 2020-02-24 10:48:43 +01:00
Leandro Lanzieri
ea8c85ae8b core/debug: Fix code style errors 2020-02-18 13:20:06 +01:00
Leandro Lanzieri
981b4eb8d0 core/debug: Fix documentation of ENABLE_DEBUG macro 2020-02-18 13:20:06 +01:00
JulianHolzwarth
ebe1bf1889 core/thread.c:thread_zombify always enables interrupts before yield 2020-02-05 18:00:13 +01:00
Karl Fessel
4445faaa3a core/shed: remove not needed bitarithm include add missing
bitarithm.h is not needed for the interface of shed but may cause conflicts
due to different definitions of SETBIT and CLRBIT

common implementations are: (value, offset) xor (value, mask) bitarithm
implements the later

frac.c and nrf52/usbdev.c use bitarithm.h but where missing the include

sam0/rtt.c defined a bit using mask from bitarithm,
changed that to the soulution used in sam0/rtc.c
2020-02-05 12:45:29 +01:00
c2534ad8f3 core: turn panic.c into a submodule 2020-01-31 13:55:26 +01:00
b6703f41dc core: turn kernel_init.c into core_init submodule 2020-01-31 13:52:13 +01:00
dec0870b4e core: cleanup kernel_init.c 2020-01-31 10:12:49 +01:00
mjc
7f44c02f45 core/ringbuffer: compensate 'ringbuffer_remove' underflow error
When rb->start = rb->size, `ringbuffer_get_one(ringbuffer_t *restrict rb)`
will read out of bounds.
2020-01-07 12:56:17 +01:00
JulianHolzwarth
2655c97fd5 core/thread.c: new function for zombie state 2019-12-11 16:48:31 +01:00
JulianHolzwarth
6b0156eac5 core/include/sched.h: new thread_status_t thread state 2019-12-11 15:44:59 +01:00
9dfcabf0d8 core: fix typos 2019-11-23 22:39:38 +01:00
Francois Berder
4a31f94cfc many typo fixes
Signed-off-by: Francois Berder <18538310+francois-berder@users.noreply.github.com>
2019-11-23 22:39:07 +01:00
Benjamin Valentin
a98a9e12e9 core: debug: introduce DEBUG_PUTS()
The DEBUG() function requires a minimal stack size for printf().
This is not always availiable.
To still allow static debug messages, introduce DEBUG_PUTS() that
gets resolved to puts() and does not carry such stack size requirements.
2019-11-20 19:09:47 +01:00
Leandro Lanzieri
0dd776a9e6 core/kernel_defines: Introduce 'IS_ACTIVE' macro.
IS_ACTIVE allows to evaluate macro definitions in non-preprocessor
expressions. It takes a macro that may be defined to 1 or not defined at
all and expands to 1 or 0 respectively.
2019-11-11 12:53:03 +01:00
fenghe
d6227cbc4d core/sched: remove duplicate include of irq.h 2019-10-31 01:28:32 +08:00
Marian Buschsieweke
e0cec17ec8
core/rmutex: Made C++ compatible 2019-10-24 23:08:36 +02:00
Gunar Schorcht
54e915eec5 core/assert: allow multiple static_asserts
Uses an own scope for the definition of the enum const to allow multiple `static_assert` statements within the same function in non-C11 environments.
2019-10-19 16:16:24 +02:00
JulianHolzwarth
fbf6a665e1 core/thread.c: change thread_getstatus return type
thread_status_t instead of int
2019-10-15 15:55:05 +02:00
Francisco Molina
1caf6610cb sys: add schedstatistics module 2019-09-13 11:37:44 +02:00
Martine Lenders
1887e9d3f4
Merge pull request #12203 from JulianHolzwarth/pr/core/thread/hotfix_prio_type
core/thread.c: thread_create fix priority type
2019-09-12 12:41:13 +02:00
JulianHolzwarth
1d16b3d5dc core/thread.c: thread_create fix priority type
Bugfix: changing type of priority to uint8_t to be consistent with struct _thread
2019-09-11 17:42:48 +02:00
Francisco Molina
fc58ebbd97 core/sched: separate sched_cb from schedstatistics 2019-09-10 17:08:21 +02:00
francisco
3d62fa05b8 core/schedstatistics: refactor
- add init_schedstatistics function to be called after
  auto_init, that way xtimer_is init is called before
  the first call to xtimer_now
- register schedstatics code as a callback to be executed
  on each sched_run()
2019-09-10 17:07:54 +02:00
Kees Bakker
2a0a36945c core: make use of ARRAY_SIZE macro 2019-08-06 19:43:54 +02:00
Benjamin Valentin
fcf31724a6 core: add ARRAY_SIZE macro 2019-08-06 19:31:10 +02:00
fdfd3133f7
core/sched_native: fix duplicate core_sched group definition
Introduce core_sched_native group and put this in group in parent
core_sched group
2019-08-05 16:57:37 +02:00
Marian Buschsieweke
7749e621b8
core: Fix undefined behaviour in C11 atomics
Casting pointers to volatile memory to pointers to regular memory is permitted,
but using those pointers to access the memory results in undefined behavior.
This commit changes the casts to no longer drop the volatile qualifier.

References: https://en.cppreference.com/w/c/language/volatile
2019-05-15 15:47:43 +02:00
be66fb0507 core/atomic_c11: fix declarations
gcc 9 started complaining about type mismatches:

1. all int sized return types are expected to be
   "unsigned int" instead of e.g., "uint32_t"

2. all arguments are expected to be passed as (volatile)
   void * pointers

This commit fixes 1. by doing ifdef'ed typedefs for I2 and I4, an fixes
2. by using void pointers, then casting within the template bodies.
2019-05-13 17:38:10 +02:00
e4fcac91a1 core/atomic_sync: guard by GCC >= 4.7
The documentation states that the implementation is missing for
gcc < 4.7, but then unconditionally compiles it, overriding the
builtins.
(gcc 9 starts complaining about mismatch of declarations.)
2019-05-13 13:18:21 +02:00
0d4f7b2715
Merge pull request #11510 from miri64/core/fix/thread_state-name-collision
core: rename thread_state_t to thread_status_t
2019-05-11 13:03:49 +02:00
Martine Lenders
db20a057ae core: rename thread_state_t to thread_status_t
This way it can't come to name collisions on `native` with Mac OSX'
threading library [1].

[1]: https://opensource.apple.com/source/xnu/xnu-792/osfmk/mach/thread_status.h.auto.html
2019-05-11 12:25:07 +02:00
87c72a8fe1 core/thread: unify thread_t variable naming
thread_t variables were named t, other_thread, cb. For consistency sake,
change all occurences to just "thread".
2019-05-11 11:39:32 +02:00
0ec9c57b2b add copyrights from IOTPUSH project 2019-05-02 12:09:37 +02:00
Hauke Petersen
c71fb4a435 core/clist: add clist_count() 2019-03-23 23:29:53 +01:00
Marian Buschsieweke
435f798a2b
core/sched: Fixed typo 2019-03-21 22:00:37 +01:00
Vincent Dupont
e8619b327b thread: allow overriding THREAD_PRIORITY_MAIN 2019-03-20 14:09:16 +01:00
Marian Buschsieweke
4c3e92f183
core: Made thread state an enum
- Introduced enum type `thread_state_t` to replace preprocessor macros
- Moved thread states to `sched.h` for two reasons:
  a) Because of the interdependencies of `sched.h` and `thread.h` keeping it in
     `thread.h` would result in ugly code.
  b) Theses thread states are defined from the schedulers point of view, so it
     actually makes senses to have it defined there
2019-02-13 13:31:52 +01:00
82b2362bc3 core/msg: add assert for problem identified in #10881 2019-01-28 17:14:16 +01:00
Kees Bakker
920d8b8805 core: remove redundant casts 2019-01-09 23:00:50 +01:00
Sebastian Meiling
52bc2b86fa doxygen: use initial capitals for group names 2019-01-09 08:42:59 +01:00
Sebastian Meiling
dceff6c22f doxygen: use ingroup instead of addtogroup in core 2019-01-09 08:42:59 +01:00
Sebastian Meiling
81e293422c doxygen: refine core_sync grouping
- Move `@defgroup core_sync` group definition to doc.txt
- Adapt usage of `@ingroup core_sync` accordingly
2019-01-09 08:42:59 +01:00
f2194a8e26 core/irq: fix 2 missing words in documentation 2019-01-07 20:50:59 +01:00
4878cf2119
Merge pull request #10400 from miri64/core/enh/thread_has_queue_func
core: provide function to check msg queue initialization
2018-12-19 18:41:39 +01:00
Martine Lenders
c8937f8d40 core: use thread_has_msg_queue() for message queue check 2018-12-19 15:39:50 +01:00
Martine Lenders
7835db5ec3 core: provide function to check msg queue initialization
This makes it easier to refactor that part of the `thread_t` structure
later on.
2018-12-19 15:39:50 +01:00
2a03e6fdbd
Merge pull request #10264 from gebart/core/schedstats_t
core: Rename typedef schedstat -> schedstat_t
2018-12-18 12:51:29 +01:00
Hauke Petersen
0e4f5bf894 core/clist: add missing function to table in doc 2018-12-11 11:15:18 +01:00
Sebastian Meiling
43d39b7a33
Merge pull request #8333 from samkumar/feature-condition-variable
core: condition variable implementation
2018-11-30 21:15:53 +01:00
Sam Kumar
fb8edbb610 core: condition variable implementation 2018-11-30 11:22:07 -08:00
Martine Lenders
28572d7d21 core: mutex: fix DEBUG pointer output 2018-11-09 08:41:50 +01:00
Joakim Nohlgård
5b68bbb2cf core: Rename typedef schedstat -> schedstat_t
To follow naming conventions
2018-10-26 09:10:21 +02:00
PeterKietzmann
0ecaaf021c core/bitarithm: add explicit 32-bit function 2018-10-08 13:57:21 +02:00
smlng
5b1cd0475f core/clist: add cppcheck-suppress nullPointer
This was found by cppcheck 1.6x used in Travis-CI, however this
seems to be a false positive, as it is not found by newer versions
of cppcheck.
2018-09-25 12:03:58 +02:00
smlng
59e299635b cppcheck: add/correct reason for cppcheck-suppress
Adding and correcting description/rational on why certain cppcheck
warnings or errors are intentionally suppressed.
2018-09-25 12:03:58 +02:00
Martine Lenders
2350c46740
Merge pull request #9826 from kaspar030/fix_byteorder_bebuf
core/byteorder: fix bebuftohs() / htobebufs() on big endian
2018-09-03 14:35:29 +02:00
Joakim Nohlgård
ab05acbf89 core: Mark openocd info variables read-only 2018-08-25 14:44:45 +02:00
2d27b32567
Merge pull request #9364 from gschorcht/thread_arch
core: add architecture dependent thread information
2018-08-24 12:10:20 +02:00
accf50ce07 core/byteorder: fix byteorder_htobebufs, byteorder_bebuftohs
Logic was swapping byte order on Big Endian platforms
2018-08-23 22:07:44 +02:00
Martine Lenders
ec7bf7a854 core: rmutex: include stdint.h
For some reason the LLVM/clang version of `stdatomic.h` does not include
`stdint.h`, though it uses types from it.
2018-08-03 18:34:56 +02:00
Gunar Schorcht
9db03537b9 core/pthread: make them compilable with g++ 2018-07-21 14:24:57 +02:00
Gunar Schorcht
e75e0a5fe6 core: architecture dependent part in thread_t 2018-07-05 09:22:59 +02:00
Gunar Schorcht
c71f40370b core: add architecture dependent extension 2018-07-05 09:22:59 +02:00
Hauke Petersen
36e0d4883d core/byteorder: to/from bufs funcs are big endian 2018-07-04 17:41:04 +02:00
Joakim Nohlgård
69fb02c3fc core: uncrustify thread_flags.h 2018-06-27 12:43:29 +02:00
2b1ed99a49 core: add more stacksize defines 2018-06-14 23:29:03 +02:00
2212850fbb core/mbox: doc typo fixes 2018-06-13 12:13:24 +02:00
bd2845adf6 core: fix doxygen grouping 2018-06-11 19:12:02 +02:00
Hauke Petersen
f68b243dfc core/byteorder: add uint16 from/to buffer funcs 2018-06-06 13:18:48 +02:00
Matthew Blue
2bd1d7f045 core/assert: provide static_assert for c99 2018-06-03 03:15:17 -04:00
Matthew Blue
38a30b68c2 core/debug: fix debug.h use within ISRs 2018-05-17 17:06:44 -04:00
8fd013635f
Merge pull request #9136 from jcarrano/fix-assert
core: make assert() an expression.
2018-05-15 21:38:14 +02:00
Juan Carrano
09d1b2eac7 core: Make assert be an expression.
The "verbose" alternative for assert() is now an expression and
can be used in all the places that a funcion call can be used.
2018-05-15 14:25:55 +02:00
7c7bb45ce7 core/clist: make clist_foreach() return break-causing node 2018-05-12 00:07:13 +02:00
d9993cc8d2
Merge pull request #8642 from OTAkeys/feat/static_assert
assert: add static_assert if using c11
2018-04-03 22:10:46 +02:00
Pieter Willemsen
729441fdb6 assert: add static_assert if using c11 2018-04-03 16:09:31 +02:00
Joakim Nohlgård
1fdfa6480d core/mutex: fix -fpermissive warning in C++ mode
g++ gives the error message "error: invalid conversion from ‘void*’ to
‘list_node*’ [-fpermissive]"
2018-03-25 09:11:26 +02:00
aa57ea5b74 core: instead of cpp-style, use C-style comments 2018-02-06 16:59:58 +01:00
Sebastian Meiling
3bb169307b
Merge pull request #8364 from smlng/osx/debug/fix_output
macOS: fix debug output
2018-01-22 15:14:48 +01:00
smlng
e017f8a5f1 core: fix format errors in debug output 2018-01-17 15:25:11 +01:00
499c1812b2 core/bitarithm: provide multiple implementations for bitarithm_lsb() 2018-01-16 22:55:26 +01:00
e6a9a760a7 core/thread: add thread_getname() dummy available without DEVELHELP 2018-01-15 14:37:04 +01:00
c001e14f9d core: debug: rely on optimizer to kick out unused debug code 2018-01-12 13:38:06 +01:00
Martine Lenders
4013adcf65
Merge pull request #8277 from miri64/doc/fix/must-not-may-not-wording
doc: Fix 'must not'/'may not' wording
2018-01-10 20:34:17 +01:00
MichelRottleuthner
ee17dae5af pkg/fatfs: add vfs integration 2018-01-09 14:46:40 +01:00
Martine Lenders
2e93ba1c50
doc: Fix 'must not'/'may not' wording
I applied the following terminology and changed the wording in the doc
accordingly:

* must not: If the parameter is of the value it *must not* be it either
  hits an assert or crashes the system.
* may not: The value can be that value, but the function will return an
  error.
2017-12-19 09:00:12 +01:00
a8ec624ac4 core: cib: fix overflow handling 2017-11-22 17:53:16 +01:00
Martine Lenders
4952ffbae7
Merge pull request #6698 from Lotterleben/doc_thread_h
thread.h: extend doc for msg_waiters and msg_array
2017-11-16 19:25:52 +01:00
Lotte Steenbrink
9cc3641b75 thread.h: extend doc for msg_waiters and msg_array 2017-11-16 10:15:46 -08:00
24e7869484 core/include/panic.h: fix typos 2017-11-16 14:40:16 +01:00
32c10ae2c9 core, cpu: rename thread_start_threading() -> cpu_switch_context_exit() 2017-11-16 14:40:16 +01:00
bb4a5c5cdf core: remove COREIF_NG 2017-11-16 14:39:54 +01:00
615b1e60bc core/clist: add argument to clist_foreach 2017-11-06 12:49:22 +01:00
f142908f4e
Merge pull request #7655 from kaspar030/add_list_sort
core/clist: add clist_sort()
2017-11-06 12:46:01 +01:00
Joe Kroesche
5b6d311830 core/include/ringbuffer.h: add doc ref to tsrb.
Updated file comment header to comply with coding standard;
added brief module description and reference to tsrb to guide reader
who might be looking for thread-safe implementation
2017-10-29 08:08:15 -05:00
Joakim Nohlgård
317b013319 core/thread_flags: Remove unused THREAD_FLAG_MUTEX_UNLOCKED
and improve docs for THREAD_FLAG_TIMEOUT
2017-10-12 14:30:59 +02:00
Travis Griggs
2fd324a52f correct print_stack macro 2017-10-03 14:39:25 -07:00
de784961fa core/clist: add clist_sort() 2017-10-03 00:36:14 +02:00
5cc8204e10 Merge pull request #7048 from smlng/enh/ps/schedstats
schedstats: revert to 32Bit, and enhance output of schedstats
2017-09-28 16:08:51 +02:00
smlng
6ac0922c7d doc: replace dashes 2017-09-06 08:49:05 +02:00
Joakim Nohlgård
a67694a8c0 core: thread_flags: Set sched_status_switch_request after waking a waiting thread 2017-08-31 22:51:28 +02:00
Joakim Nohlgård
5dd38c68e2 Merge pull request #7536 from kaspar030/improve_thread_flags_docs
core: thread_flags: improve documentation
2017-08-30 20:44:04 +02:00
ee945978e9 core: thread_flags: improve documentation 2017-08-30 13:43:02 +02:00
Joakim Nohlgård
ef01efc387 core/msg: Set THREAD_FLAG_MSG_WAITING when queueing messages 2017-08-30 12:04:47 +02:00
Joakim Nohlgård
87d322556a core/thread: fix Doxygen nesting
Everything below the thread states was cut off in the module
documentation because Doxygen does not handle nested @name tags.
2017-08-11 07:47:09 +02:00
68f13467d3 core: remove redundant includes 2017-08-02 14:27:55 +02:00
7a0fcc30c8 sys: add initial SSP support 2017-06-27 18:05:14 +02:00
smlng
e7136e2dde schedstats: revert #6975, use 32Bit again 2017-06-08 14:33:47 +02:00
Raul Fuentes
f21d497be4 tread.h: Minor examples compile 2017-05-30 20:48:57 +02:00
0fcc7d3834 cleanup: apply headerguard script output 2017-05-24 17:54:02 +02:00
Sebastian Meiling
dd4f8f7704 Merge pull request #6975 from OTAkeys/pr/ps_schedstatistics_fix
ps: fix schedstatistics
2017-05-17 13:50:42 +02:00
Vincent Dupont
6d5b95517d ps: fix schedstatistics
Fix xtimer_now() usage and fix columns alignment in ps command when
module schedstatistics is used.
2017-05-16 10:33:42 +02:00
Hauke Petersen
f914ae4876 core/panic: enable panic modes for Cortex-M7 2017-05-08 09:16:11 +02:00
89390a83d4 core: byteorder.h: rename HTON* -> hton*, NTOH* -> ntoh* 2017-04-13 10:59:39 +02:00
smlng
4ffbbfb8f6 doc: correct naming of doxygen group in core 2017-04-10 16:11:49 +02:00
0b10dccf64 core: adapt to Makefile.submodule 2017-03-28 20:50:48 +02:00
smlng
1b69f281f9 core, log: fix tautology compare error with toolchain llvm 2017-03-17 09:04:09 +01:00
Simon Brummer
68581a8fbe core: bugfix: ringbuffer_remove 2017-03-01 22:01:26 +01:00
8d207ca724 Merge pull request #5731 from melshuber/master
core: recursive mutex implementation
2017-02-21 14:03:14 +01:00
Martin Elshuber
6cd3d34686 Removed duplicated code, fixed comment 2017-02-20 12:11:02 +01:00
Joakim Nohlgård
47e970635b core: Fix assert printf format string
cppcheck said: core/assert.c:23: warning (invalidPrintfArgType_sint): %d in
format string (no. 2) requires 'int' but the argument type is 'unsigned
int'.
2017-02-16 17:11:22 +01:00
smlng
f4d9972574 llvm: hide redefines of atomic sync operations 2017-02-14 10:53:12 +01:00
Martin Elshuber
b9c2fc8254 Added reentrant mutex implementation
In contrast to normal mutexes, reeentrant mutexes allow to be relocked
multiple times from the same thread.
2017-02-09 15:17:39 +01:00
Joakim Nohlgård
4fdd2ea41a core: Remove atomic in favour of C11 stdatomic 2017-02-08 16:23:50 +01:00
Joakim Nohlgård
4297e06fe5 core: add __sync_x library helpers for <gcc-4.7 2017-02-08 16:23:47 +01:00
Joakim Nohlgård
fcdb157228 core: rename c11_atomic -> atomic_c11 2017-02-08 16:23:47 +01:00
Joakim Nohlgård
6d20ac084b core/c11_atomic.c: Add remaining C11 atomic library helpers for GCC 2017-02-08 16:23:47 +01:00
Joakim Nohlgård
d322af3fe5 core/include/mutex.h: remove unused #include "atomic.h" 2017-02-08 16:23:47 +01:00
Joakim Nohlgård
985afd8d80 core/mutex.c: remove unused #include "atomic.h" 2017-02-08 16:23:47 +01:00
smlng
0d4855c256 core: fix osx compile issue 2017-02-01 09:06:48 +01:00
Oleg Hahm
c5abb08316 Merge pull request #4058 from daniel-k/pr/gdb_threads_openocd
cortex_m: Add debug symbols for OpenOCD/GDB thread support
2017-01-25 17:49:42 +01:00
smlng
66c02daeae core: doc typos 2017-01-20 13:35:57 +01:00
Oleg Hahm
7ee7801c10 *: remove trailing underscores from header guards 2017-01-19 18:30:53 +01:00
daniel-k
9d403d95ce cortex_m: Add debug symbols for OpenOCD/GDB thread support 2017-01-16 20:50:35 +01:00
Oleg Hahm
4e068bc1a4 doc: core: fix formatting 2017-01-16 18:04:04 +01:00