Changeset da1bafb in mainline for kernel/generic/include/synch


Ignore:
Timestamp:
2010-05-24T18:57:31Z (15 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
Location:
kernel/generic/include/synch
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/include/synch/mutex.h

    r666f492 rda1bafb  
    5050} mutex_t;
    5151
    52 #define mutex_lock(mtx)                 \
     52#define mutex_lock(mtx) \
    5353        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
    54 #define mutex_trylock(mtx)              \
     54
     55#define mutex_trylock(mtx) \
    5556        _mutex_lock_timeout((mtx), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
    56 #define mutex_lock_timeout(mtx, usec)   \
     57
     58#define mutex_lock_timeout(mtx, usec) \
    5759        _mutex_lock_timeout((mtx), (usec), SYNCH_FLAGS_NON_BLOCKING)
    5860
    5961extern void mutex_initialize(mutex_t *, mutex_type_t);
    60 extern int _mutex_lock_timeout(mutex_t *, uint32_t, int);
     62extern int _mutex_lock_timeout(mutex_t *, uint32_t, unsigned int);
    6163extern void mutex_unlock(mutex_t *);
    6264
  • kernel/generic/include/synch/rwlock.h

    r666f492 rda1bafb  
    4848
    4949typedef struct {
    50         SPINLOCK_DECLARE(lock);
     50        IRQ_SPINLOCK_DECLARE(lock);
     51       
    5152        /**
    5253         * Mutex for writers, readers can bypass it if readers_in is positive.
     54         *
    5355         */
    5456        mutex_t exclusive;
     57       
    5558        /** Number of readers in critical section. */
    5659        size_t readers_in;
     
    5962#define rwlock_write_lock(rwl) \
    6063        _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     64
    6165#define rwlock_read_lock(rwl) \
    6266        _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     67
    6368#define rwlock_write_trylock(rwl) \
    6469        _rwlock_write_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    6570            SYNCH_FLAGS_NON_BLOCKING)
     71
    6672#define rwlock_read_trylock(rwl) \
    6773        _rwlock_read_lock_timeout((rwl), SYNCH_NO_TIMEOUT, \
    6874            SYNCH_FLAGS_NON_BLOCKING)
     75
    6976#define rwlock_write_lock_timeout(rwl, usec) \
    7077        _rwlock_write_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
     78
    7179#define rwlock_read_lock_timeout(rwl, usec) \
    7280        _rwlock_read_lock_timeout((rwl), (usec), SYNCH_FLAGS_NONE)
    7381
    74 extern void rwlock_initialize(rwlock_t *rwl);
    75 extern void rwlock_read_unlock(rwlock_t *rwl);
    76 extern void rwlock_write_unlock(rwlock_t *rwl);
    77 extern int _rwlock_read_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
    78 extern int _rwlock_write_lock_timeout(rwlock_t *rwl, uint32_t usec, int flags);
     82extern void rwlock_initialize(rwlock_t *);
     83extern void rwlock_read_unlock(rwlock_t *);
     84extern void rwlock_write_unlock(rwlock_t *);
     85extern int _rwlock_read_lock_timeout(rwlock_t *, uint32_t, unsigned int);
     86extern int _rwlock_write_lock_timeout(rwlock_t *, uint32_t, unsigned int);
    7987
    8088#endif
  • kernel/generic/include/synch/semaphore.h

    r666f492 rda1bafb  
    4646#define semaphore_down(s) \
    4747        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NONE)
     48
    4849#define semaphore_trydown(s) \
    4950        _semaphore_down_timeout((s), SYNCH_NO_TIMEOUT, SYNCH_FLAGS_NON_BLOCKING)
     51
    5052#define semaphore_down_timeout(s, usec) \
    5153        _semaphore_down_timeout((s), (usec), SYNCH_FLAGS_NONE)
    5254
    53 extern void semaphore_initialize(semaphore_t *s, int val);
    54 extern int _semaphore_down_timeout(semaphore_t *s, uint32_t usec, int flags);
    55 extern void semaphore_up(semaphore_t *s);
     55extern void semaphore_initialize(semaphore_t *, int);
     56extern int _semaphore_down_timeout(semaphore_t *, uint32_t, unsigned int);
     57extern void semaphore_up(semaphore_t *);
    5658
    5759#endif
  • kernel/generic/include/synch/spinlock.h

    r666f492 rda1bafb  
    170170#define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name)
    171171
    172 #define ASSERT_SPINLOCK(expr, lock)
     172#define ASSERT_SPINLOCK(expr, lock)  ASSERT(expr)
    173173
    174174#define spinlock_initialize(lock, name)
  • kernel/generic/include/synch/waitq.h

    r666f492 rda1bafb  
    4646} wakeup_mode_t;
    4747
    48 /** Wait queue structure. */
     48/** Wait queue structure.
     49 *
     50 */
    4951typedef struct {
    50 
    5152        /** Lock protecting wait queue structure.
    5253         *
    5354         * Must be acquired before T.lock for each T of type thread_t.
    5455         */
    55         SPINLOCK_DECLARE(lock);
    56 
     56        IRQ_SPINLOCK_DECLARE(lock);
     57       
    5758        /**
    5859         * Number of waitq_wakeup() calls that didn't find a thread to wake up.
     60         *
    5961         */
    6062        int missed_wakeups;
     63       
    6164        /** List of sleeping threads for wich there was no missed_wakeup. */
    6265        link_t head;
     
    6972
    7073extern void waitq_initialize(waitq_t *);
    71 extern int waitq_sleep_timeout(waitq_t *, uint32_t, int);
     74extern int waitq_sleep_timeout(waitq_t *, uint32_t, unsigned int);
    7275extern ipl_t waitq_sleep_prepare(waitq_t *);
    73 extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, int);
     76extern int waitq_sleep_timeout_unsafe(waitq_t *, uint32_t, unsigned int);
    7477extern void waitq_sleep_finish(waitq_t *, int, ipl_t);
    7578extern void waitq_wakeup(waitq_t *, wakeup_mode_t);
Note: See TracChangeset for help on using the changeset viewer.