mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
xtimer/xtimer.c: _mutex_remove_thread_from_waiting_queue
This function tries to remove the thread from a mutex waiting queue. The value pointed to by unlocked will be set to 1 if the thread was removed from the waiting queue otherwise 0.
This commit is contained in:
parent
bce45fd9d8
commit
4d85fa16e0
@ -208,7 +208,10 @@ void xtimer_now_timex(timex_t *out)
|
||||
out->microseconds = now - (out->seconds * US_PER_SEC);
|
||||
}
|
||||
|
||||
static int _mutex_remove_thread_from_waiting_queue(mutex_t *mutex, thread_t *thread)
|
||||
/*
|
||||
* The value pointed to by unlocked will be set to 1 if the thread was removed from the waiting queue otherwise 0.
|
||||
*/
|
||||
static void _mutex_remove_thread_from_waiting_queue(mutex_t *mutex, thread_t *thread, volatile uint8_t *unlocked)
|
||||
{
|
||||
unsigned irqstate = irq_disable();
|
||||
assert(mutex != NULL && thread != NULL);
|
||||
@ -220,14 +223,16 @@ static int _mutex_remove_thread_from_waiting_queue(mutex_t *mutex, thread_t *thr
|
||||
if (mutex->queue.next == NULL) {
|
||||
mutex->queue.next = MUTEX_LOCKED;
|
||||
}
|
||||
*unlocked = 1;
|
||||
|
||||
sched_set_status(thread, STATUS_PENDING);
|
||||
irq_restore(irqstate);
|
||||
sched_switch(thread->priority);
|
||||
return 1;
|
||||
return;
|
||||
}
|
||||
}
|
||||
*unlocked = 0;
|
||||
irq_restore(irqstate);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void _mutex_timeout(void *arg)
|
||||
@ -243,7 +248,7 @@ static void _mutex_timeout(void *arg)
|
||||
|
||||
mutex_thread_t *mt = (mutex_thread_t *)arg;
|
||||
mt->blocking = 0;
|
||||
mt->got_unlocked = _mutex_remove_thread_from_waiting_queue(mt->mutex, mt->thread);
|
||||
_mutex_remove_thread_from_waiting_queue(mt->mutex, mt->thread, &mt->dequeued);
|
||||
irq_restore(irqstate);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user