Changeset b59318e in mainline for kernel/generic/src/synch/waitq.c


Ignore:
Timestamp:
2018-06-26T17:34:48Z (6 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ab6edb6
Parents:
f6372be9
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-26 17:01:43)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-26 17:34:48)
Message:

Make futex able to time out.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/synch/waitq.c

    rf6372be9 rb59318e  
    5757#include <adt/list.h>
    5858#include <arch/cycle.h>
     59#include <mem.h>
    5960
    6061static void waitq_sleep_timed_out(void *);
     
    7172void waitq_initialize(waitq_t *wq)
    7273{
     74        memsetb(wq, sizeof(*wq), 0);
    7375        irq_spinlock_initialize(&wq->lock, "wq.lock");
    7476        list_initialize(&wq->sleepers);
    75         wq->missed_wakeups = 0;
    7677}
    7778
     
    114115                thread->saved_context = thread->sleep_timeout_context;
    115116                do_wakeup = true;
     117                if (thread->sleep_composable)
     118                        wq->ignore_wakeups++;
    116119                thread->sleep_queue = NULL;
    117120                irq_spinlock_unlock(&wq->lock, false);
     
    176179                list_remove(&thread->wq_link);
    177180                thread->saved_context = thread->sleep_interruption_context;
     181                if (thread->sleep_composable)
     182                        wq->ignore_wakeups++;
    178183                do_wakeup = true;
    179184                thread->sleep_queue = NULL;
     
    393398         */
    394399        irq_spinlock_lock(&THREAD->lock, false);
     400
     401        THREAD->sleep_composable = (flags & SYNCH_FLAGS_FUTEX);
    395402
    396403        if (flags & SYNCH_FLAGS_INTERRUPTIBLE) {
     
    538545        assert(irq_spinlock_locked(&wq->lock));
    539546
     547        if (wq->ignore_wakeups > 0) {
     548                if (mode == WAKEUP_FIRST) {
     549                        wq->ignore_wakeups--;
     550                        return;
     551                }
     552                wq->ignore_wakeups = 0;
     553        }
     554
    540555loop:
    541556        if (list_empty(&wq->sleepers)) {
Note: See TracChangeset for help on using the changeset viewer.