mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-16 10:03:50 +01:00
core: thread: Added validation of pid
This commit is contained in:
parent
d005861f5c
commit
bad2b5c187
@ -69,8 +69,12 @@ int thread_wakeup(kernel_pid_t pid)
|
|||||||
|
|
||||||
unsigned old_state = disableIRQ();
|
unsigned old_state = disableIRQ();
|
||||||
|
|
||||||
thread_t *other_thread = (thread_t *) sched_threads[pid];
|
thread_t *other_thread = (thread_t *) thread_get(pid);
|
||||||
if (other_thread && other_thread->status == STATUS_SLEEPING) {
|
|
||||||
|
if (!other_thread) {
|
||||||
|
DEBUG("thread_wakeup: Thread does not exist!\n");
|
||||||
|
}
|
||||||
|
else if (other_thread->status == STATUS_SLEEPING) {
|
||||||
DEBUG("thread_wakeup: Thread is sleeping.\n");
|
DEBUG("thread_wakeup: Thread is sleeping.\n");
|
||||||
|
|
||||||
sched_set_status(other_thread, STATUS_RUNNING);
|
sched_set_status(other_thread, STATUS_RUNNING);
|
||||||
@ -82,10 +86,10 @@ int thread_wakeup(kernel_pid_t pid)
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
DEBUG("thread_wakeup: Thread is not sleeping!\n");
|
DEBUG("thread_wakeup: Thread is not sleeping!\n");
|
||||||
|
}
|
||||||
|
|
||||||
restoreIRQ(old_state);
|
restoreIRQ(old_state);
|
||||||
return STATUS_NOT_FOUND;
|
return STATUS_NOT_FOUND;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void thread_yield(void)
|
void thread_yield(void)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user