core: disallow msg_send_receive() on same thread
This commit is contained in:
parent
8da80ee878
commit
bb306038ae
@ -184,6 +184,9 @@ int msg_try_receive(msg_t *m);
|
|||||||
*
|
*
|
||||||
* @note CAUTION! Use this function only when receiver is already waiting.
|
* @note CAUTION! Use this function only when receiver is already waiting.
|
||||||
* If not use simple msg_send()
|
* If not use simple msg_send()
|
||||||
|
*
|
||||||
|
* @pre @p target_pid is not the PID of the current thread.
|
||||||
|
*
|
||||||
* @param[in] m Pointer to preallocated ``msg_t`` structure with
|
* @param[in] m Pointer to preallocated ``msg_t`` structure with
|
||||||
* the message to send, must not be NULL.
|
* the message to send, must not be NULL.
|
||||||
* @param[out] reply Pointer to preallocated msg. Reply will be written
|
* @param[out] reply Pointer to preallocated msg. Reply will be written
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
#include <assert.h>
|
||||||
#include "kernel.h"
|
#include "kernel.h"
|
||||||
#include "sched.h"
|
#include "sched.h"
|
||||||
#include "msg.h"
|
#include "msg.h"
|
||||||
@ -214,6 +215,7 @@ int msg_send_int(msg_t *m, kernel_pid_t target_pid)
|
|||||||
|
|
||||||
int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
|
int msg_send_receive(msg_t *m, msg_t *reply, kernel_pid_t target_pid)
|
||||||
{
|
{
|
||||||
|
assert(sched_active_pid != target_pid);
|
||||||
unsigned state = disableIRQ();
|
unsigned state = disableIRQ();
|
||||||
tcb_t *me = (tcb_t*) sched_threads[sched_active_pid];
|
tcb_t *me = (tcb_t*) sched_threads[sched_active_pid];
|
||||||
sched_set_status(me, STATUS_REPLY_BLOCKED);
|
sched_set_status(me, STATUS_REPLY_BLOCKED);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user