Changeset 05e2a7ad in mainline for generic/src/synch/waitq.c


Ignore:
Timestamp:
2005-12-07T13:32:31Z (19 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
839470f
Parents:
253f8590
Message:

Add comments describing locking rules for some locks.
Cleanup.

File:
1 edited

Legend:

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

    r253f8590 r05e2a7ad  
    3434#include <arch/asm.h>
    3535#include <arch/types.h>
     36#include <typedefs.h>
    3637#include <time/timeout.h>
    3738#include <arch.h>
     
    6869        thread_t *t = (thread_t *) data;
    6970        waitq_t *wq;
    70         int do_wakeup = 0;
     71        bool do_wakeup = false;
    7172
    7273        spinlock_lock(&threads_lock);
     
    7677grab_locks:
    7778        spinlock_lock(&t->lock);
    78         if (wq = t->sleep_queue) {
     79        if (wq = t->sleep_queue) {              /* assignment */
    7980                if (!spinlock_trylock(&wq->lock)) {
    8081                        spinlock_unlock(&t->lock);
    81                         goto grab_locks; /* avoid deadlock */
     82                        goto grab_locks;        /* avoid deadlock */
    8283                }
    8384
    8485                list_remove(&t->wq_link);
    8586                t->saved_context = t->sleep_timeout_context;
    86                 do_wakeup = 1;
     87                do_wakeup = true;
    8788               
    8889                spinlock_unlock(&wq->lock);
     
    9091        }
    9192       
    92         t->timeout_pending = 0;
     93        t->timeout_pending = false;
    9394        spinlock_unlock(&t->lock);
    9495       
    95         if (do_wakeup) thread_ready(t);
     96        if (do_wakeup)
     97                thread_ready(t);
    9698
    9799out:
     
    194196                        return ESYNCH_TIMEOUT;
    195197                }
    196                 THREAD->timeout_pending = 1;
     198                THREAD->timeout_pending = true;
    197199                timeout_register(&THREAD->sleep_timeout, (__u64) usec, waitq_interrupted_sleep, THREAD);
    198200        }
     
    228230 *        will be woken up and missed count will be zeroed.
    229231 */
    230 void waitq_wakeup(waitq_t *wq, int all)
     232void waitq_wakeup(waitq_t *wq, bool all)
    231233{
    232234        ipl_t ipl;
     
    251253 *        will be woken up and missed count will be zeroed.
    252254 */
    253 void _waitq_wakeup_unsafe(waitq_t *wq, int all)
     255void _waitq_wakeup_unsafe(waitq_t *wq, bool all)
    254256{
    255257        thread_t *t;
     
    258260        if (list_empty(&wq->head)) {
    259261                wq->missed_wakeups++;
    260                 if (all) wq->missed_wakeups = 0;
     262                if (all)
     263                        wq->missed_wakeups = 0;
    261264                return;
    262265        }
     
    267270        spinlock_lock(&t->lock);
    268271        if (t->timeout_pending && timeout_unregister(&t->sleep_timeout))
    269                 t->timeout_pending = 0;
     272                t->timeout_pending = false;
    270273        t->sleep_queue = NULL;
    271274        spinlock_unlock(&t->lock);
     
    273276        thread_ready(t);
    274277
    275         if (all) goto loop;
    276 }
     278        if (all)
     279                goto loop;
     280}
Note: See TracChangeset for help on using the changeset viewer.