Ignore:
Timestamp:
2018-09-07T15:41:29Z (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:
077842c
Parents:
508b0df1
Message:

Improve kernel spinlock and AS refcount.

File:
1 edited

Legend:

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

    r508b0df1 r78de83de  
    3636#define KERN_SPINLOCK_H_
    3737
     38#include <assert.h>
     39#include <stdatomic.h>
    3840#include <stdbool.h>
    39 #include <barrier.h>
    40 #include <assert.h>
    4141#include <preemption.h>
    42 #include <atomic.h>
    4342#include <arch/asm.h>
    4443
     
    4645
    4746typedef struct spinlock {
    48         atomic_t val;
     47        atomic_flag flag;
    4948
    5049#ifdef CONFIG_DEBUG_SPINLOCK
     
    7069        spinlock_t lock_name = { \
    7170                .name = desc_name, \
    72                 .val = { 0 } \
     71                .flag = ATOMIC_FLAG_INIT \
    7372        }
    7473
     
    7675        static spinlock_t lock_name = { \
    7776                .name = desc_name, \
    78                 .val = { 0 } \
     77                .flag = ATOMIC_FLAG_INIT \
    7978        }
    8079
     
    8988#define SPINLOCK_INITIALIZE_NAME(lock_name, desc_name) \
    9089        spinlock_t lock_name = { \
    91                 .val = { 0 } \
     90                .flag = ATOMIC_FLAG_INIT \
    9291        }
    9392
    9493#define SPINLOCK_STATIC_INITIALIZE_NAME(lock_name, desc_name) \
    9594        static spinlock_t lock_name = { \
    96                 .val = { 0 } \
     95                .flag = ATOMIC_FLAG_INIT \
    9796        }
    9897
     
    126125NO_TRACE static inline void spinlock_unlock_nondebug(spinlock_t *lock)
    127126{
    128         /*
    129          * Prevent critical section code from bleeding out this way down.
    130          */
    131         CS_LEAVE_BARRIER();
    132 
    133         atomic_set(&lock->val, 0);
     127        atomic_flag_clear_explicit(&lock->flag, memory_order_release);
    134128        preemption_enable();
    135129}
     
    215209                .lock = { \
    216210                        .name = desc_name, \
    217                         .val = { 0 } \
     211                        .flag = ATOMIC_FLAG_INIT \
    218212                }, \
    219213                .guard = false, \
     
    225219                .lock = { \
    226220                        .name = desc_name, \
    227                         .val = { 0 } \
     221                        .flag = ATOMIC_FLAG_INIT \
    228222                }, \
    229223                .guard = false, \
     
    236230        irq_spinlock_t lock_name = { \
    237231                .lock = { \
    238                         .val = { 0 } \
     232                        .flag = ATOMIC_FLAG_INIT \
    239233                }, \
    240234                .guard = false, \
     
    245239        static irq_spinlock_t lock_name = { \
    246240                .lock = { \
    247                         .val = { 0 } \
     241                        .flag = ATOMIC_FLAG_INIT \
    248242                }, \
    249243                .guard = false, \
Note: See TracChangeset for help on using the changeset viewer.