Commit Graph

67 Commits (13832d8e621027bfbd636b32d4c29ede32178e9d)

Author SHA1 Message Date
Lucas Jenss 426170b064 Improve naming of thread stacksize/priority constants
As discussed in #2725, this commit renames a number of stacksize constants to
better convey their intended usage. In addition, constants for thread priority
are given a `THREAD_` prefix. Changes are:

* KERNEL_CONF_STACKSIZE_PRINTF renamed to THREAD_EXTRA_STACKSIZE_PRINTF
* KERNEL_CONF_STACKSIZE_DEFAULT renamed to THREAD_STACKSIZE_DEFAULT
* KERNEL_CONF_STACKSIZE_IDLE renamed to THREAD_STACKSIZE_IDLE
* KERNEL_CONF_STACKSIZE_MAIN renamed to THREAD_STACKSIZE_MAIN
* Move thread stacksizes from kernel.h to thread.h, since the prefix changed
* PRIORITY_MIN renamed to THREAD_PRIORITY_MIN
* PRIORITY_IDLE renamed to THREAD_PRIORITY_IDLE
* PRIORITY_MAIN renamed to THREAD_PRIORITY_MAIN
* Move thread priorities from kernel.h to thread.h since the prefix has changed
* MINIMUM_STACK_SIZE renamed to THREAD_STACKSIZE_MINIMUM for consistency
8 years ago
Martine Lenders 4e7a32efc1 core: Allow debug messages without DEVELHELP 9 years ago
René Kijewski 5f29fed076 core: introduce `msg_sent_by_int()`
msg_send_int() sets `m->sender_pid = target_pid`. This was used to flag a
message as having been sent by an ISR.

This PR introduces a static inline function `msg_sent_by_int()` and a
specific define for this purpose.
9 years ago
Martine Lenders c0b0110de9 core: Fix msg_send_receive
Fixes #1935
9 years ago
Ludwig Ortmann b4d9c9e6b7 core/msg: coding convention cleanup 9 years ago
Ludwig Ortmann 535839f2d5 core/msg: use disable/restoreIRQ
* needed to change internal `msg_send` to allow external disabling of interrupts
9 years ago
René Kijewski ff2a1dc61b core: remove needless test in msg.c
`thread.c` initializes a thread with an empty message queue. `cib_put()`
will `return -1` for an empty CIB, so there is no need to test if
`thread->msg_array != NULL`.
9 years ago
Oleg Hahm a262de0678 core: always set sender_pid in msg_send_int 9 years ago
René Kijewski c3ba66781d core: put more intelligence into `queue_msg()`
Fixes #1942.

There were two instances were it was not checked the target thread has a
message queue before queuing the message.

This PR centralizes the check into `queue_msg()`.
9 years ago
Oleg Hahm 8dab420321 Merge pull request #1835 from OlegHahm/msg_receive_yield
core: msg_receive should yield
9 years ago
Oleg Hahm 4fd3d62f2a core: msg_receive should yield
If a thread sends blocking, but the target thread is not currently in
receive mode, the sender gets queued. If it has a higher priority it
should run again as soon as the target goes into receiving mode.
9 years ago
Ludwig Ortmann eceb656c49 core,sys: fix storage types for irq API usage
* should not have any effect as long as `unsigned` and `int` are compatible
* also fix two cosmetic `unsigned int` -> `unsigned` for consistency
9 years ago
René Kijewski 677d690e2b core: introduce thread_yield_higher(), yield less
Fixes #1708.

Currently involuntary preemption causes the current thread not only to
yield for a higher prioritized thread, but all other threads of its own
priority class, too.

This PR adds the function `thread_yield_higher()`, which will yield the
current thread in favor of higher prioritized functions, but not for
threads of its own priority class.

Boards now need to implement `thread_yield_higher()` instead of
`thread_yield()`, but `COREIF_NG` boards are not affected in any way.

`thread_yield()` retains its old meaning: yield for every thread that
has the same or a higher priority.

This PR does not touch the occurrences of `thread_yield()` in the periph
drivers, because the author of this PR did not look into the logic of
the various driver implementations.
9 years ago
Kaspar Schleiser 5146c66786 core: adapt to msg_try_send 9 years ago
Kaspar Schleiser bdcac07faa core: msg: introduce msg_try_send 9 years ago
Ludwig Ortmann cd3dff3f2e core/msg: add DEVELHELP checks for valid pid 9 years ago
Ludwig Ortmann c2b2e4554b core/queue: queue -> priority_queue
Rename queue to priority queue, because that's what it is.
9 years ago
Oleg Hahm 983d056c75 core: harmonizes the data type for the process ID
Instead of using differing integer types use kernel_pid_t for process
identifier. This type is introduced in a new header file to avoid
circular dependencies.
9 years ago
Ludwig Ortmann 3ca4f18479 doc: use lgplv2.1-short license header instead of lgpl-short-riot 9 years ago
Ludwig Ortmann b6846e31fc doc: fix most occurences of FU as an author
.. but only if there are other authors as well
9 years ago
Ludwig Ortmann 2a859c78cd SQUASHME: do it right 9 years ago
Ludwig Ortmann d8a5ee1ec8 core/msg: set m->sender_pid before it is used
fixes `msg_send_to_self` condition
9 years ago
Ludwig Ortmann b6f2426d16 core/msg: revert part of #1285
use m->sender_pid instead of sched_active_pid again
undoes the optimization intended by #1285
fixes uint/int warning
9 years ago
Ludwig Ortmann 5c9a975afb core/msg: fix, optimize and improve
fixes:
fix race conditions by reordering dINTs
prevent null pointer dereference by adding forgotten target check
add forgotten eINTs
replace printf with DEBUG
fix debug messages

optimizations:
optimize pid access
reorder msg_send switches

improvements:
add debug statements
add missing return value to msg_send_to_self documentation
9 years ago
Oleg Hahm ef5ec344fd core: prefix API functions correctly
Also changed names for bitarithm functions and rename thread_pid to sched_active_pid.
9 years ago
Christian Mehlis 7b91ea9349 core: fix warning about discarding volatile 10 years ago
Kévin Roussel 24f5cfafbb Add the ability to send a message to the current thread's message queue
(without raising an error)
10 years ago
Kaspar Schleiser 622d473eb3 core: msg: yield after queueing of a message if REPLY_BLOCKED
When setting the running task reply_blocked, it is implicitly removed
from the runqueue. But if queueing of a msg is actually successful, the
thread exits msg_send without yielding, continuing to run even if it's
not supposed to.

Nice example of why multiple function exit points lead to weird
errors...
10 years ago
Kaspar Schleiser 8d07b131db core: msg: add some debug statements 10 years ago
Kaspar Schleiser 210a20b807 core: msg: don't wake up sender after receive if it's REPLY_BLOCKED
solves issue #100

If the sender is reply-blocked, waking it up after its message has been
delivered is wrong. It needs to stay reply-blocked until the reply has
been delivered.
10 years ago
Kaspar Schleiser 56ee585c81 update Kaspar's email address
kaspar.schleiser@fu-berlin.de is obsolete.
(2nd try, first try was overwritten by some overzealous documenter)
10 years ago
Oleg Hahm 903ec54a43 making include directives consistent 10 years ago
Hauke Petersen 3785fe956b Fixed doxygen comments, focused on file headers and group definitions 10 years ago
Kaspar Schleiser aaf325c290 Merge pull request #400 from kaspar030/msg_cleanup
msg.c cleanup
10 years ago
Kaspar Schleiser 23ecbde1a3 core: msg: whitespace fixes 10 years ago
Kaspar Schleiser 94283789a7 core: msg: rename "n" to something more expressive ("queue_index") 10 years ago
Kaspar Schleiser af542058ee core: msg: whitespace fixes 10 years ago
Kaspar Schleiser f85adf608f change my email address
kaspar.schleiser@fu-berlin.de will be obsoleted soon. Replace it with
kaspar@schleiser.de, which will (hopefully) stay.
10 years ago
Ludwig Ortmann d6c213fb47 fix grammar in license header 10 years ago
Oleg Hahm e44412d0c1 added debug information to msg_send (similar to msg_send_int) 10 years ago
Ludwig Ortmann f1b89df8d8 explain the "brainfuck condition" 10 years ago
Ludwig Ortmann 5e6cc92291 harmonize msg.c DEBUG statements
Use same order (function: [thread_name:] message) throughout msg.c.
Begin message with a capital letter.
10 years ago
Ludwig Ortmann 2d1303763e fix spelling in msg.c 10 years ago
Christian Mehlis 9ace6b4807 add missing inttypes include for PRI macros 10 years ago
Christian Mehlis 21ffebc197 add check for a not existing thread 10 years ago
LudwigOrtmann 07c7e8ccd3 Merge pull request #90 from OlegHahm/milestone_1_0_fixes
Milestone 1 0 fixes
10 years ago
Oleg Hahm 836ae0d291 fix #11: initialize queue_node_t n.next in msg_send() 10 years ago
Christian Mehlis 62994314aa in msg_send_receive: return result from msg_send 10 years ago
Oleg Hahm 599e266b55 Revert "removed redefined ENABLE_DEBUG"
This reverts commit 69c526f44d.

Instead of removing ENABLE_DEBUG, define it as zero and replacing the
ifdef preprocessor commands by a simple #if
10 years ago
Christian Mehlis c5e62e238b add missing include 10 years ago