Changeset 3679f51a in mainline for uspace/lib/c/include


Ignore:
Timestamp:
2018-06-25T20:41:09Z (7 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:
95838f1
Parents:
d73d992
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 20:30:35)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-06-25 20:41:09)
Message:

Remove the option of RCU-upgradable futexes for now.
They complicate threading design too much.

Location:
uspace/lib/c/include
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/futex.h

    rd73d992 r3679f51a  
    4242typedef struct futex {
    4343        atomic_t val;
    44 #ifdef FUTEX_UPGRADABLE
    45         int upgraded;
    46 #endif
    4744} futex_t;
    48 
    4945
    5046extern void futex_initialize(futex_t *futex, int value);
    5147
    52 #ifdef FUTEX_UPGRADABLE
    53 #include <rcu.h>
    54 
    55 #define FUTEX_INITIALIZE(val) {{ (val) }, 0}
    56 
    57 #define futex_lock(fut) \
    58 ({ \
    59         rcu_read_lock(); \
    60         (fut)->upgraded = rcu_access(_upgrade_futexes); \
    61         if ((fut)->upgraded) \
    62                 (void) futex_down((fut)); \
    63 })
    64 
    65 #define futex_trylock(fut) \
    66 ({ \
    67         rcu_read_lock(); \
    68         int _upgraded = rcu_access(_upgrade_futexes); \
    69         if (_upgraded) { \
    70                 int _acquired = futex_trydown((fut)); \
    71                 if (!_acquired) { \
    72                         rcu_read_unlock(); \
    73                 } else { \
    74                         (fut)->upgraded = true; \
    75                 } \
    76                 _acquired; \
    77         } else { \
    78                 (fut)->upgraded = false; \
    79                 1; \
    80         } \
    81 })
    82 
    83 #define futex_unlock(fut) \
    84 ({ \
    85         if ((fut)->upgraded) \
    86                 (void) futex_up((fut)); \
    87         rcu_read_unlock(); \
    88 })
    89 
    90 extern int _upgrade_futexes;
    91 
    92 extern void futex_upgrade_all_and_wait(void);
    93 
    94 #else
    95 
    9648#define FUTEX_INITIALIZE(val) {{ (val) }}
     49#define FUTEX_INITIALIZER     FUTEX_INITIALIZE(1)
    9750
    9851#define futex_lock(fut)     (void) futex_down((fut))
    9952#define futex_trylock(fut)  futex_trydown((fut))
    10053#define futex_unlock(fut)   (void) futex_up((fut))
    101 
    102 #endif
    103 
    104 #define FUTEX_INITIALIZER     FUTEX_INITIALIZE(1)
    10554
    10655/** Try to down the futex.
  • uspace/lib/c/include/rcu.h

    rd73d992 r3679f51a  
    9292#define rcu_access(ptr) ACCESS_ONCE(ptr)
    9393
    94 typedef enum blocking_mode {
    95         BM_BLOCK_FIBRIL,
    96         BM_BLOCK_THREAD
    97 } blocking_mode_t;
    98 
    9994extern void rcu_register_fibril(void);
    10095extern void rcu_deregister_fibril(void);
     
    105100extern bool rcu_read_locked(void);
    106101
    107 #define rcu_synchronize() _rcu_synchronize(BM_BLOCK_FIBRIL)
    108 
    109 extern void _rcu_synchronize(blocking_mode_t);
     102extern void rcu_synchronize(void);
    110103
    111104#endif
Note: See TracChangeset for help on using the changeset viewer.