Changeset da1bafb in mainline for kernel/generic/src/synch/semaphore.c


Ignore:
Timestamp:
2010-05-24T18:57:31Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0095368
Parents:
666f492
Message:

major code revision

  • replace spinlocks taken with interrupts disabled with irq_spinlocks
  • change spacing (not indendation) to be tab-size independent
  • use unsigned integer types where appropriate (especially bit flags)
  • visual separation
  • remove argument names in function prototypes
  • string changes
  • correct some formating directives
  • replace various cryptic single-character variables (t, a, m, c, b, etc.) with proper identifiers (thread, task, timeout, as, itm, itc, etc.)
  • unify some assembler constructs
  • unused page table levels are now optimized out in compile time
  • replace several ints (with boolean semantics) with bools
  • use specifically sized types instead of generic types where appropriate (size_t, uint32_t, btree_key_t)
  • improve comments
  • split asserts with conjuction into multiple independent asserts
File:
1 edited

Legend:

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

    r666f492 rda1bafb  
    3333/**
    3434 * @file
    35  * @brief       Semaphores.
     35 * @brief Semaphores.
    3636 */
    3737
     
    4747 * Initialize semaphore.
    4848 *
    49  * @param s Semaphore.
     49 * @param sem Semaphore.
    5050 * @param val Maximal number of threads allowed to enter critical section.
     51 *
    5152 */
    52 void semaphore_initialize(semaphore_t *s, int val)
     53void semaphore_initialize(semaphore_t *sem, int val)
    5354{
    54         ipl_t ipl;
     55        waitq_initialize(&sem->wq);
    5556       
    56         waitq_initialize(&s->wq);
    57        
    58         ipl = interrupts_disable();
    59 
    60         spinlock_lock(&s->wq.lock);
    61         s->wq.missed_wakeups = val;
    62         spinlock_unlock(&s->wq.lock);
    63 
    64         interrupts_restore(ipl);
     57        irq_spinlock_lock(&sem->wq.lock, true);
     58        sem->wq.missed_wakeups = val;
     59        irq_spinlock_unlock(&sem->wq.lock, true);
    6560}
    6661
     
    7065 * Conditional mode and mode with timeout can be requested.
    7166 *
    72  * @param s Semaphore.
    73  * @param usec Timeout in microseconds.
     67 * @param sem  Semaphore.
     68 * @param usec  Timeout in microseconds.
    7469 * @param flags Select mode of operation.
    7570 *
     
    7873 *
    7974 * @return See comment for waitq_sleep_timeout().
     75 *
    8076 */
    81 int _semaphore_down_timeout(semaphore_t *s, uint32_t usec, int flags)
     77int _semaphore_down_timeout(semaphore_t *sem, uint32_t usec, unsigned int flags)
    8278{
    83         return waitq_sleep_timeout(&s->wq, usec, flags);
     79        return waitq_sleep_timeout(&sem->wq, usec, flags);
    8480}
    8581
     
    8985 *
    9086 * @param s Semaphore.
     87 *
    9188 */
    92 void semaphore_up(semaphore_t *s)
     89void semaphore_up(semaphore_t *sem)
    9390{
    94         waitq_wakeup(&s->wq, WAKEUP_FIRST);
     91        waitq_wakeup(&sem->wq, WAKEUP_FIRST);
    9592}
    9693
Note: See TracChangeset for help on using the changeset viewer.