tests/xtimer_mutex_lock_timeout/main.c: Function to terminate
The function will terminate the thread and send the message m to target_pid.
This commit is contained in:
parent
714ee17fab
commit
d9aec38f1f
@ -62,6 +62,26 @@ static const shell_command_t shell_commands[] = {
|
|||||||
*/
|
*/
|
||||||
static char t_stack[THREAD_STACKSIZE_DEFAULT];
|
static char t_stack[THREAD_STACKSIZE_DEFAULT];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief send message and suicide thread
|
||||||
|
*
|
||||||
|
* This function will send a message to a thread without yielding
|
||||||
|
* and terminates the calling thread. This can be used to wakeup a
|
||||||
|
* thread and terminating yourself.
|
||||||
|
* This function calls sched_task_exit()
|
||||||
|
*
|
||||||
|
* @param[in] m Pointer to preallocated @ref msg_t structure, must
|
||||||
|
* not be NULL.
|
||||||
|
* @param[in] target_pid PID of target thread
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static NORETURN void msg_send_sched_task_exit(msg_t *m, kernel_pid_t target_pid)
|
||||||
|
{
|
||||||
|
(void)irq_disable();
|
||||||
|
msg_send_int(m, target_pid);
|
||||||
|
sched_task_exit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief thread function for
|
* @brief thread function for
|
||||||
* cmd_test_xtimer_mutex_lock_timeout_low_prio_thread
|
* cmd_test_xtimer_mutex_lock_timeout_low_prio_thread
|
||||||
@ -77,11 +97,9 @@ void *thread_low_prio_test(void *arg)
|
|||||||
thread_wakeup(main_thread_pid);
|
thread_wakeup(main_thread_pid);
|
||||||
|
|
||||||
mutex_unlock(test_mutex);
|
mutex_unlock(test_mutex);
|
||||||
(void)irq_disable();
|
|
||||||
puts("THREAD low prio: exiting low");
|
|
||||||
msg_send_int(&msg, main_thread_pid);
|
|
||||||
|
|
||||||
sched_task_exit();
|
puts("THREAD low prio: exiting low");
|
||||||
|
msg_send_sched_task_exit(&msg, main_thread_pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user