Changes in / [64e9cf4:f114d40] in mainline


Ignore:
Location:
kernel
Files:
1 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/arch/asm.h

    r64e9cf4 rf114d40  
    5858        }
    5959}
    60 
    61 #define ARCH_SPIN_HINT() asm volatile ("pause\n")
    6260
    6361/** Byte from port
  • kernel/arch/arm32/include/arch/asm.h

    r64e9cf4 rf114d40  
    6565}
    6666
    67 #ifdef PROCESSOR_ARCH_armv7_a
    68 #define ARCH_SPIN_HINT() asm volatile ("yield")
    69 #endif
    70 
    7167_NO_TRACE static inline void pio_write_8(ioport8_t *port, uint8_t v)
    7268{
  • kernel/arch/arm64/include/arch/asm.h

    r64e9cf4 rf114d40  
    6060                ;
    6161}
    62 
    63 #define ARCH_SPIN_HINT() asm volatile ("yield")
    6462
    6563/** Output byte to port.
  • kernel/arch/ia32/include/arch/asm.h

    r64e9cf4 rf114d40  
    6363        );
    6464}
    65 
    66 #define ARCH_SPIN_HINT() asm volatile ("pause\n")
    6765
    6866#define GEN_READ_REG(reg) _NO_TRACE static inline sysarg_t read_ ##reg (void) \
  • kernel/arch/mips32/src/mips32.c

    r64e9cf4 rf114d40  
    4141#include <str.h>
    4242#include <mem.h>
    43 #include <preemption.h>
    4443#include <userspace.h>
    4544#include <stdbool.h>
  • kernel/arch/ppc32/src/mm/frame.c

    r64e9cf4 rf114d40  
    3333 */
    3434
    35 #include <arch/asm.h>
    3635#include <arch/boot/boot.h>
    3736#include <arch/mm/frame.h>
  • kernel/generic/include/arch.h

    r64e9cf4 rf114d40  
    7575typedef struct {
    7676        size_t preemption;      /**< Preemption disabled counter and flag. */
    77         size_t mutex_locks;
    7877        struct thread *thread;  /**< Current thread. */
    7978        struct task *task;      /**< Current task. */
  • kernel/generic/include/mm/tlb.h

    r64e9cf4 rf114d40  
    3636#define KERN_TLB_H_
    3737
    38 #include <arch/asm.h>
    3938#include <arch/mm/asid.h>
    4039#include <typedefs.h>
  • kernel/generic/include/synch/spinlock.h

    r64e9cf4 rf114d40  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
    3  * Copyright (c) 2023 Jiří Zárevúcky
    43 * All rights reserved.
    54 *
     
    3736#define KERN_SPINLOCK_H_
    3837
     38#include <assert.h>
    3939#include <stdatomic.h>
    4040#include <stdbool.h>
    41 
    42 #include <arch/types.h>
    43 #include <assert.h>
     41#include <preemption.h>
     42#include <arch/asm.h>
     43
     44#ifdef CONFIG_SMP
     45
     46typedef struct spinlock {
     47        atomic_flag flag;
     48
     49#ifdef CONFIG_DEBUG_SPINLOCK
     50        const char *name;
     51#endif /* CONFIG_DEBUG_SPINLOCK */
     52} spinlock_t;
     53
     54/*
     55 * SPINLOCK_DECLARE is to be used for dynamically allocated spinlocks,
     56 * where the lock gets initialized in run time.
     57 */
     58#define SPINLOCK_DECLARE(lock_name)  spinlock_t lock_name
     59#define SPINLOCK_EXTERN(lock_name)   extern spinlock_t lock_name
     60
     61/*
     62 * SPINLOCK_INITIALIZE and SPINLOCK_STATIC_INITIALIZE are to be used
     63 * for statically allocated spinlocks. They declare (either as global
     64 * or static) symbol and initialize the lock.
     65 */
     66#ifdef CONFIG_DEBUG_SPINLOCK
     67
     68#define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     69        spinlock_t lock_name = { \
     70                .name = desc_name, \
     71                .flag = ATOMIC_FLAG_INIT \
     72        }
     73
     74#define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
     75        static spinlock_t lock_name = { \
     76                .name = desc_name, \
     77                .flag = ATOMIC_FLAG_INIT \
     78        }
     79
     80#define ASSERT_SPINLOCK(expr, lock) \
     81        assert_verbose(expr, (lock)->name)
     82
     83#define spinlock_lock(lock)    spinlock_lock_debug((lock))
     84#define spinlock_unlock(lock)  spinlock_unlock_debug((lock))
     85
     86#else /* CONFIG_DEBUG_SPINLOCK */
     87
     88#define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     89        spinlock_t lock_name = { \
     90                .flag = ATOMIC_FLAG_INIT \
     91        }
     92
     93#define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
     94        static spinlock_t lock_name = { \
     95                .flag = ATOMIC_FLAG_INIT \
     96        }
     97
     98#define ASSERT_SPINLOCK(expr, lock) \
     99        assert(expr)
     100
     101/** Acquire spinlock
     102 *
     103 * @param lock  Pointer to spinlock_t structure.
     104 */
     105_NO_TRACE static inline void spinlock_lock(spinlock_t *lock)
     106{
     107        preemption_disable();
     108        while (atomic_flag_test_and_set_explicit(&lock->flag,
     109            memory_order_acquire))
     110                ;
     111}
     112
     113/** Release spinlock
     114 *
     115 * @param lock  Pointer to spinlock_t structure.
     116 */
     117_NO_TRACE static inline void spinlock_unlock(spinlock_t *lock)
     118{
     119        atomic_flag_clear_explicit(&lock->flag, memory_order_release);
     120        preemption_enable();
     121}
     122
     123#endif /* CONFIG_DEBUG_SPINLOCK */
     124
     125#define SPINLOCK_INITIALIZE(lock_name) \
     126        SPINLOCK_INITIALIZE_NAME(lock_name, #lock_name)
     127
     128#define SPINLOCK_STATIC_INITIALIZE(lock_name) \
     129        SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name)
     130
     131extern void spinlock_initialize(spinlock_t *, const char *);
     132extern bool spinlock_trylock(spinlock_t *);
     133extern void spinlock_lock_debug(spinlock_t *);
     134extern void spinlock_unlock_debug(spinlock_t *);
     135extern bool spinlock_locked(spinlock_t *);
     136
     137#ifdef CONFIG_DEBUG_SPINLOCK
     138
     139#include <log.h>
    44140
    45141#define DEADLOCK_THRESHOLD  100000000
    46 
    47 #if defined(CONFIG_SMP) && defined(CONFIG_DEBUG_SPINLOCK)
    48 
    49 #include <log.h>
    50142
    51143#define DEADLOCK_PROBE_INIT(pname)  size_t pname = 0
     
    67159#endif /* CONFIG_DEBUG_SPINLOCK */
    68160
    69 typedef struct spinlock {
    70 #ifdef CONFIG_SMP
    71         atomic_flag flag;
    72 
    73 #ifdef CONFIG_DEBUG_SPINLOCK
    74         const char *name;
    75 #endif /* CONFIG_DEBUG_SPINLOCK */
    76 #endif
    77 } spinlock_t;
    78 
    79 /*
    80  * SPINLOCK_DECLARE is to be used for dynamically allocated spinlocks,
    81  * where the lock gets initialized in run time.
    82  */
    83 #define SPINLOCK_DECLARE(lock_name)  spinlock_t lock_name
    84 #define SPINLOCK_EXTERN(lock_name)   extern spinlock_t lock_name
    85 
    86 #ifdef CONFIG_SMP
    87 #ifdef CONFIG_DEBUG_SPINLOCK
    88 #define SPINLOCK_INITIALIZER(desc_name) { .name = (desc_name), .flag = ATOMIC_FLAG_INIT }
    89 #else
    90 #define SPINLOCK_INITIALIZER(desc_name) { .flag = ATOMIC_FLAG_INIT }
    91 #endif
    92 #else
    93 #define SPINLOCK_INITIALIZER(desc_name) {}
    94 #endif
    95 
    96 /*
    97  * SPINLOCK_INITIALIZE and SPINLOCK_STATIC_INITIALIZE are to be used
    98  * for statically allocated spinlocks. They declare (either as global
    99  * or static) symbol and initialize the lock.
    100  */
    101 #define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
    102         spinlock_t lock_name = SPINLOCK_INITIALIZER(desc_name)
    103 
    104 #define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
    105         static spinlock_t lock_name = SPINLOCK_INITIALIZER(desc_name)
    106 
    107 #if defined(CONFIG_SMP) && defined(CONFIG_DEBUG_SPINLOCK)
    108 #define ASSERT_SPINLOCK(expr, lock) assert_verbose(expr, (lock)->name)
    109 #else /* CONFIG_DEBUG_SPINLOCK */
    110 #define ASSERT_SPINLOCK(expr, lock) assert(expr)
    111 #endif /* CONFIG_DEBUG_SPINLOCK */
    112 
    113 #define SPINLOCK_INITIALIZE(lock_name) \
    114         SPINLOCK_INITIALIZE_NAME(lock_name, #lock_name)
    115 
    116 #define SPINLOCK_STATIC_INITIALIZE(lock_name) \
    117         SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, #lock_name)
    118 
    119 extern void spinlock_initialize(spinlock_t *, const char *);
    120 extern bool spinlock_trylock(spinlock_t *);
    121 extern void spinlock_lock(spinlock_t *);
    122 extern void spinlock_unlock(spinlock_t *);
    123 extern bool spinlock_locked(spinlock_t *);
     161#else /* CONFIG_SMP */
     162
     163/* On UP systems, spinlocks are effectively left out. */
     164
     165/* Allow the use of spinlock_t as an incomplete type. */
     166typedef struct spinlock spinlock_t;
     167
     168#define SPINLOCK_DECLARE(name)
     169#define SPINLOCK_EXTERN(name)
     170
     171#define SPINLOCK_INITIALIZE(name)
     172#define SPINLOCK_STATIC_INITIALIZE(name)
     173
     174#define SPINLOCK_INITIALIZE_NAME(name, desc_name)
     175#define SPINLOCK_STATIC_INITIALIZE_NAME(name, desc_name)
     176
     177#define ASSERT_SPINLOCK(expr, lock)  assert(expr)
     178
     179#define spinlock_initialize(lock, name)
     180
     181#define spinlock_lock(lock)     preemption_disable()
     182#define spinlock_trylock(lock)  ({ preemption_disable(); 1; })
     183#define spinlock_unlock(lock)   preemption_enable()
     184#define spinlock_locked(lock)   1
     185#define spinlock_unlocked(lock) 1
     186
     187#define DEADLOCK_PROBE_INIT(pname)
     188#define DEADLOCK_PROBE(pname, value)
     189
     190#endif /* CONFIG_SMP */
    124191
    125192typedef struct {
    126         spinlock_t lock;              /**< Spinlock */
    127         bool guard;                   /**< Flag whether ipl is valid */
    128         ipl_t ipl;                    /**< Original interrupt level */
    129 #ifdef CONFIG_DEBUG_SPINLOCK
    130         _Atomic(struct cpu *) owner;  /**< Which cpu currently owns this lock */
    131 #endif
     193        SPINLOCK_DECLARE(lock);  /**< Spinlock */
     194        bool guard;              /**< Flag whether ipl is valid */
     195        ipl_t ipl;               /**< Original interrupt level */
    132196} irq_spinlock_t;
    133197
     
    135199#define IRQ_SPINLOCK_EXTERN(lock_name)   extern irq_spinlock_t lock_name
    136200
     201#ifdef CONFIG_SMP
     202
    137203#define ASSERT_IRQ_SPINLOCK(expr, irq_lock) \
    138204        ASSERT_SPINLOCK(expr, &((irq_lock)->lock))
    139 
    140 #define IRQ_SPINLOCK_INITIALIZER(desc_name) \
    141         { \
    142                 .lock = SPINLOCK_INITIALIZER(desc_name), \
    143                 .guard = false, \
    144                 .ipl = 0, \
    145         }
    146205
    147206/*
     
    150209 * as global or static symbol) and initialize the lock.
    151210 */
     211#ifdef CONFIG_DEBUG_SPINLOCK
     212
    152213#define IRQ_SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
    153         irq_spinlock_t lock_name = IRQ_SPINLOCK_INITIALIZER(desc_name)
     214        irq_spinlock_t lock_name = { \
     215                .lock = { \
     216                        .name = desc_name, \
     217                        .flag = ATOMIC_FLAG_INIT \
     218                }, \
     219                .guard = false, \
     220                .ipl = 0 \
     221        }
    154222
    155223#define IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
    156         static irq_spinlock_t lock_name = IRQ_SPINLOCK_INITIALIZER(desc_name)
     224        static irq_spinlock_t lock_name = { \
     225                .lock = { \
     226                        .name = desc_name, \
     227                        .flag = ATOMIC_FLAG_INIT \
     228                }, \
     229                .guard = false, \
     230                .ipl = 0 \
     231        }
     232
     233#else /* CONFIG_DEBUG_SPINLOCK */
     234
     235#define IRQ_SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     236        irq_spinlock_t lock_name = { \
     237                .lock = { \
     238                        .flag = ATOMIC_FLAG_INIT \
     239                }, \
     240                .guard = false, \
     241                .ipl = 0 \
     242        }
     243
     244#define IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
     245        static irq_spinlock_t lock_name = { \
     246                .lock = { \
     247                        .flag = ATOMIC_FLAG_INIT \
     248                }, \
     249                .guard = false, \
     250                .ipl = 0 \
     251        }
     252
     253#endif /* CONFIG_DEBUG_SPINLOCK */
     254
     255#else /* CONFIG_SMP */
     256
     257/*
     258 * Since the spinlocks are void on UP systems, we also need
     259 * to have a special variant of interrupts-disabled spinlock
     260 * macros which take this into account.
     261 */
     262
     263#define ASSERT_IRQ_SPINLOCK(expr, irq_lock) \
     264        ASSERT_SPINLOCK(expr, NULL)
     265
     266#define IRQ_SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
     267        irq_spinlock_t lock_name = { \
     268                .guard = false, \
     269                .ipl = 0 \
     270        }
     271
     272#define IRQ_SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
     273        static irq_spinlock_t lock_name = { \
     274                .guard = false, \
     275                .ipl = 0 \
     276        }
     277
     278#endif /* CONFIG_SMP */
    157279
    158280#define IRQ_SPINLOCK_INITIALIZE(lock_name) \
  • kernel/generic/meson.build

    r64e9cf4 rf114d40  
    101101        'src/smp/smp.c',
    102102        'src/synch/condvar.c',
    103         'src/synch/irq_spinlock.c',
    104103        'src/synch/mutex.c',
    105104        'src/synch/semaphore.c',
  • kernel/generic/src/synch/spinlock.c

    r64e9cf4 rf114d40  
    11/*
    22 * Copyright (c) 2001-2004 Jakub Jermar
    3  * Copyright (c) 2023 Jiří Zárevúcky
    43 * All rights reserved.
    54 *
     
    3736 */
    3837
    39 #include <arch/asm.h>
    4038#include <synch/spinlock.h>
    4139#include <atomic.h>
     
    4947#include <cpu.h>
    5048
    51 #ifndef ARCH_SPIN_HINT
    52 #define ARCH_SPIN_HINT() ((void)0)
    53 #endif
     49#ifdef CONFIG_SMP
    5450
    5551/** Initialize spinlock
     
    6056void spinlock_initialize(spinlock_t *lock, const char *name)
    6157{
    62 #ifdef CONFIG_SMP
    6358        atomic_flag_clear_explicit(&lock->flag, memory_order_relaxed);
    6459#ifdef CONFIG_DEBUG_SPINLOCK
    6560        lock->name = name;
    6661#endif
    67 #endif
    68 }
     62}
     63
     64#ifdef CONFIG_DEBUG_SPINLOCK
    6965
    7066/** Lock spinlock
    7167 *
     68 * Lock spinlock.
     69 * This version has limitted ability to report
     70 * possible occurence of deadlock.
     71 *
    7272 * @param lock Pointer to spinlock_t structure.
    7373 *
    7474 */
    75 void spinlock_lock(spinlock_t *lock)
    76 {
     75void spinlock_lock_debug(spinlock_t *lock)
     76{
     77        size_t i = 0;
     78        bool deadlock_reported = false;
     79
    7780        preemption_disable();
    78 
    79 #ifdef CONFIG_SMP
    80         bool deadlock_reported = false;
    81         size_t i = 0;
    82 
    8381        while (atomic_flag_test_and_set_explicit(&lock->flag, memory_order_acquire)) {
    84                 ARCH_SPIN_HINT();
    85 
    86 #ifdef CONFIG_DEBUG_SPINLOCK
    8782                /*
    8883                 * We need to be careful about particular locks
     
    116111                        deadlock_reported = true;
    117112                }
    118 #endif
    119         }
    120 
    121         /* Avoid compiler warning with debug disabled. */
    122         (void) i;
     113        }
    123114
    124115        if (deadlock_reported)
    125116                printf("cpu%u: not deadlocked\n", CPU->id);
     117}
     118
     119/** Unlock spinlock
     120 *
     121 * Unlock spinlock.
     122 *
     123 * @param sl Pointer to spinlock_t structure.
     124 */
     125void spinlock_unlock_debug(spinlock_t *lock)
     126{
     127        ASSERT_SPINLOCK(spinlock_locked(lock), lock);
     128
     129        atomic_flag_clear_explicit(&lock->flag, memory_order_release);
     130        preemption_enable();
     131}
    126132
    127133#endif
    128 }
    129 
    130 /** Unlock spinlock
    131  *
    132  * @param sl Pointer to spinlock_t structure.
    133  */
    134 void spinlock_unlock(spinlock_t *lock)
    135 {
    136 #ifdef CONFIG_SMP
    137 #ifdef CONFIG_DEBUG_SPINLOCK
    138         ASSERT_SPINLOCK(spinlock_locked(lock), lock);
    139 #endif
    140 
    141         atomic_flag_clear_explicit(&lock->flag, memory_order_release);
    142 #endif
    143 
    144         preemption_enable();
    145 }
    146 
    147 /**
     134
     135/** Lock spinlock conditionally
     136 *
    148137 * Lock spinlock conditionally. If the spinlock is not available
    149138 * at the moment, signal failure.
     
    151140 * @param lock Pointer to spinlock_t structure.
    152141 *
    153  * @return true on success.
     142 * @return Zero on failure, non-zero otherwise.
    154143 *
    155144 */
     
    157146{
    158147        preemption_disable();
    159 
    160 #ifdef CONFIG_SMP
    161148        bool ret = !atomic_flag_test_and_set_explicit(&lock->flag, memory_order_acquire);
    162149
     
    165152
    166153        return ret;
    167 #else
    168         return true;
    169 #endif
    170154}
    171155
     
    177161bool spinlock_locked(spinlock_t *lock)
    178162{
    179 #ifdef CONFIG_SMP
    180163        // NOTE: Atomic flag doesn't support simple atomic read (by design),
    181164        //       so instead we test_and_set and then clear if necessary.
     
    187170                atomic_flag_clear_explicit(&lock->flag, memory_order_relaxed);
    188171        return ret;
    189 #else
    190         return true;
     172}
     173
    191174#endif
     175
     176/** Initialize interrupts-disabled spinlock
     177 *
     178 * @param lock IRQ spinlock to be initialized.
     179 * @param name IRQ spinlock name.
     180 *
     181 */
     182void irq_spinlock_initialize(irq_spinlock_t *lock, const char *name)
     183{
     184        spinlock_initialize(&(lock->lock), name);
     185        lock->guard = false;
     186        lock->ipl = 0;
     187}
     188
     189/** Lock interrupts-disabled spinlock
     190 *
     191 * Lock a spinlock which requires disabled interrupts.
     192 *
     193 * @param lock    IRQ spinlock to be locked.
     194 * @param irq_dis If true, disables interrupts before locking the spinlock.
     195 *                If false, interrupts are expected to be already disabled.
     196 *
     197 */
     198void irq_spinlock_lock(irq_spinlock_t *lock, bool irq_dis)
     199{
     200        if (irq_dis) {
     201                ipl_t ipl = interrupts_disable();
     202                spinlock_lock(&(lock->lock));
     203
     204                lock->guard = true;
     205                lock->ipl = ipl;
     206        } else {
     207                ASSERT_IRQ_SPINLOCK(interrupts_disabled(), lock);
     208
     209                spinlock_lock(&(lock->lock));
     210                ASSERT_IRQ_SPINLOCK(!lock->guard, lock);
     211        }
     212}
     213
     214/** Unlock interrupts-disabled spinlock
     215 *
     216 * Unlock a spinlock which requires disabled interrupts.
     217 *
     218 * @param lock    IRQ spinlock to be unlocked.
     219 * @param irq_res If true, interrupts are restored to previously
     220 *                saved interrupt level.
     221 *
     222 */
     223void irq_spinlock_unlock(irq_spinlock_t *lock, bool irq_res)
     224{
     225        ASSERT_IRQ_SPINLOCK(interrupts_disabled(), lock);
     226
     227        if (irq_res) {
     228                ASSERT_IRQ_SPINLOCK(lock->guard, lock);
     229
     230                lock->guard = false;
     231                ipl_t ipl = lock->ipl;
     232
     233                spinlock_unlock(&(lock->lock));
     234                interrupts_restore(ipl);
     235        } else {
     236                ASSERT_IRQ_SPINLOCK(!lock->guard, lock);
     237                spinlock_unlock(&(lock->lock));
     238        }
     239}
     240
     241/** Lock interrupts-disabled spinlock
     242 *
     243 * Lock an interrupts-disabled spinlock conditionally. If the
     244 * spinlock is not available at the moment, signal failure.
     245 * Interrupts are expected to be already disabled.
     246 *
     247 * @param lock IRQ spinlock to be locked conditionally.
     248 *
     249 * @return Zero on failure, non-zero otherwise.
     250 *
     251 */
     252bool irq_spinlock_trylock(irq_spinlock_t *lock)
     253{
     254        ASSERT_IRQ_SPINLOCK(interrupts_disabled(), lock);
     255        bool ret = spinlock_trylock(&(lock->lock));
     256
     257        ASSERT_IRQ_SPINLOCK((!ret) || (!lock->guard), lock);
     258        return ret;
     259}
     260
     261/** Pass lock from one interrupts-disabled spinlock to another
     262 *
     263 * Pass lock from one IRQ spinlock to another IRQ spinlock
     264 * without enabling interrupts during the process.
     265 *
     266 * The first IRQ spinlock is supposed to be locked.
     267 *
     268 * @param unlock IRQ spinlock to be unlocked.
     269 * @param lock   IRQ spinlock to be locked.
     270 *
     271 */
     272void irq_spinlock_pass(irq_spinlock_t *unlock, irq_spinlock_t *lock)
     273{
     274        ASSERT_IRQ_SPINLOCK(interrupts_disabled(), unlock);
     275
     276        /* Pass guard from unlock to lock */
     277        bool guard = unlock->guard;
     278        ipl_t ipl = unlock->ipl;
     279        unlock->guard = false;
     280
     281        spinlock_unlock(&(unlock->lock));
     282        spinlock_lock(&(lock->lock));
     283
     284        ASSERT_IRQ_SPINLOCK(!lock->guard, lock);
     285
     286        if (guard) {
     287                lock->guard = true;
     288                lock->ipl = ipl;
     289        }
     290}
     291
     292/** Hand-over-hand locking of interrupts-disabled spinlocks
     293 *
     294 * Implement hand-over-hand locking between two interrupts-disabled
     295 * spinlocks without enabling interrupts during the process.
     296 *
     297 * The first IRQ spinlock is supposed to be locked.
     298 *
     299 * @param unlock IRQ spinlock to be unlocked.
     300 * @param lock   IRQ spinlock to be locked.
     301 *
     302 */
     303void irq_spinlock_exchange(irq_spinlock_t *unlock, irq_spinlock_t *lock)
     304{
     305        ASSERT_IRQ_SPINLOCK(interrupts_disabled(), unlock);
     306
     307        spinlock_lock(&(lock->lock));
     308        ASSERT_IRQ_SPINLOCK(!lock->guard, lock);
     309
     310        /* Pass guard from unlock to lock */
     311        if (unlock->guard) {
     312                lock->guard = true;
     313                lock->ipl = unlock->ipl;
     314                unlock->guard = false;
     315        }
     316
     317        spinlock_unlock(&(unlock->lock));
     318}
     319
     320/** Find out whether the IRQ spinlock is currently locked.
     321 *
     322 * @param lock          IRQ spinlock.
     323 * @return              True if the IRQ spinlock is locked, false otherwise.
     324 */
     325bool irq_spinlock_locked(irq_spinlock_t *ilock)
     326{
     327        return spinlock_locked(&ilock->lock);
    192328}
    193329
  • kernel/generic/src/synch/waitq.c

    r64e9cf4 rf114d40  
    4848#include <synch/waitq.h>
    4949#include <synch/spinlock.h>
    50 #include <preemption.h>
    5150#include <proc/thread.h>
    5251#include <proc/scheduler.h>
  • kernel/generic/src/time/clock.c

    r64e9cf4 rf114d40  
    5959#include <ddi/ddi.h>
    6060#include <arch/cycle.h>
    61 #include <preemption.h>
    6261
    6362/* Pointer to variable with uptime */
Note: See TracChangeset for help on using the changeset viewer.