Ignore:
Timestamp:
2018-09-06T20:21:52Z (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:
78de83de, fc10e1b
Parents:
4621d23
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-08-13 03:53:39)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-06 20:21:52)
Message:

Remove uspace <atomic.h>, use <stdatomic.h> instead

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/thread/fibril.c

    r4621d23 r508b0df1  
    8888/* This futex serializes access to global data. */
    8989static futex_t fibril_futex = FUTEX_INITIALIZER;
    90 static futex_t ready_semaphore = FUTEX_INITIALIZE(0);
     90static futex_t ready_semaphore;
    9191static long ready_st_count;
    9292
     
    117117}
    118118
    119 static inline long _ready_count(void)
    120 {
    121         /*
    122          * The number of available tokens is always equal to the number
    123          * of fibrils in the ready list + the number of free IPC buffer
    124          * buckets.
    125          */
    126 
    127         if (multithreaded)
    128                 return atomic_get(&ready_semaphore.val);
    129 
    130         _ready_debug_check();
    131         return ready_st_count;
    132 }
    133 
    134119static inline void _ready_up(void)
    135120{
     
    152137}
    153138
    154 static atomic_t threads_in_ipc_wait = { 0 };
     139static atomic_int threads_in_ipc_wait;
    155140
    156141/** Function that spans the whole life-cycle of a fibril.
     
    303288        fibril_t *f = list_pop(&ready_list, fibril_t, link);
    304289        if (!f)
    305                 atomic_inc(&threads_in_ipc_wait);
     290                atomic_fetch_add_explicit(&threads_in_ipc_wait, 1,
     291                    memory_order_relaxed);
    306292        if (!locked)
    307293                futex_unlock(&fibril_futex);
     
    317303        rc = _ipc_wait(&call, expires);
    318304
    319         atomic_dec(&threads_in_ipc_wait);
     305        atomic_fetch_sub_explicit(&threads_in_ipc_wait, 1,
     306            memory_order_relaxed);
    320307
    321308        if (rc != EOK && rc != ENOENT) {
     
    386373        _ready_up();
    387374
    388         if (atomic_get(&threads_in_ipc_wait)) {
     375        if (atomic_load_explicit(&threads_in_ipc_wait, memory_order_relaxed)) {
    389376                DPRINTF("Poking.\n");
    390377                /* Wakeup one thread sleeping in SYS_IPC_WAIT. */
     
    811798        if (!multithreaded) {
    812799                _ready_debug_check();
    813                 atomic_set(&ready_semaphore.val, ready_st_count);
     800                futex_initialize(&ready_semaphore, ready_st_count);
    814801                multithreaded = true;
    815802        }
Note: See TracChangeset for help on using the changeset viewer.