Changeset a35b458 in mainline for uspace/lib/c/generic/rcu.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/rcu.c

    r3061bc1 ra35b458  
    169169{
    170170        assert(!fibril_rcu.registered);
    171        
     171
    172172        futex_down(&rcu.list_futex);
    173173        list_append(&fibril_rcu.link, &rcu.fibrils_list);
    174174        futex_up(&rcu.list_futex);
    175        
     175
    176176        fibril_rcu.registered = true;
    177177}
     
    185185{
    186186        assert(fibril_rcu.registered);
    187        
     187
    188188        /*
    189189         * Forcefully unlock any reader sections. The fibril is exiting
     
    194194        memory_barrier();
    195195        fibril_rcu.nesting_cnt = 0;
    196        
     196
    197197        futex_down(&rcu.list_futex);
    198198        list_remove(&fibril_rcu.link);
     
    209209{
    210210        assert(fibril_rcu.registered);
    211        
     211
    212212        size_t nesting_cnt = ACCESS_ONCE(fibril_rcu.nesting_cnt);
    213        
     213
    214214        if (0 == (nesting_cnt >> RCU_NESTING_SHIFT)) {
    215215                ACCESS_ONCE(fibril_rcu.nesting_cnt) = ACCESS_ONCE(rcu.reader_group);
     
    226226        assert(fibril_rcu.registered);
    227227        assert(rcu_read_locked());
    228        
     228
    229229        /* Required by MB_FORCE_U */
    230230        compiler_barrier(); /* CC_BAR_U */
     
    243243{
    244244        assert(!rcu_read_locked());
    245        
     245
    246246        /* Contain load of rcu.cur_gp. */
    247247        memory_barrier();
     
    249249        /* Approximately the number of the GP in progress. */
    250250        size_t gp_in_progress = ACCESS_ONCE(rcu.cur_gp);
    251        
     251
    252252        lock_sync(blocking_mode);
    253        
     253
    254254        /*
    255255         * Exit early if we were stuck waiting for the mutex for a full grace
     
    264264                return;
    265265        }
    266        
     266
    267267        ++ACCESS_ONCE(rcu.cur_gp);
    268        
     268
    269269        /*
    270270         * Pairs up with MB_FORCE_L (ie CC_BAR_L). Makes changes prior
     
    272272         */
    273273        memory_barrier(); /* MB_A */
    274        
     274
    275275        /*
    276276         * Pairs up with MB_A.
     
    290290         */
    291291        force_mb_in_all_threads(); /* MB_FORCE_L */
    292        
     292
    293293        /*
    294294         * Pairs with MB_FORCE_L (ie CC_BAR_L, CC_BAR_U) and makes the most
     
    296296         */
    297297        read_barrier(); /* MB_B */
    298        
     298
    299299        size_t new_reader_group = get_other_group(rcu.reader_group);
    300300        wait_for_readers(new_reader_group, blocking_mode);
    301        
     301
    302302        /* Separates waiting for readers in new_reader_group from group flip. */
    303303        memory_barrier();
    304        
     304
    305305        /* Flip the group new readers should associate with. */
    306306        size_t old_reader_group = rcu.reader_group;
     
    309309        /* Flip the group before waiting for preexisting readers in the old group.*/
    310310        memory_barrier();
    311        
     311
    312312        wait_for_readers(old_reader_group, blocking_mode);
    313        
     313
    314314        /* MB_FORCE_U  */
    315315        force_mb_in_all_threads(); /* MB_FORCE_U */
    316        
     316
    317317        unlock_sync();
    318318}
     
    333333{
    334334        futex_down(&rcu.list_futex);
    335        
     335
    336336        list_t quiescent_fibrils;
    337337        list_initialize(&quiescent_fibrils);
    338        
     338
    339339        while (!list_empty(&rcu.fibrils_list)) {
    340340                list_foreach_safe(rcu.fibrils_list, fibril_it, next_fibril) {
    341341                        fibril_rcu_data_t *fib = member_to_inst(fibril_it,
    342342                                fibril_rcu_data_t, link);
    343                        
     343
    344344                        if (is_preexisting_reader(fib, reader_group)) {
    345345                                futex_up(&rcu.list_futex);
     
    354354                }
    355355        }
    356        
     356
    357357        list_concat(&rcu.fibrils_list, &quiescent_fibrils);
    358358        futex_up(&rcu.list_futex);
     
    366366                        blocked_fibril_t blocked_fib;
    367367                        blocked_fib.id = fibril_get_id();
    368                                
     368
    369369                        list_append(&blocked_fib.link, &rcu.sync_lock.blocked_fibrils);
    370                        
     370
    371371                        do {
    372372                                blocked_fib.is_ready = false;
     
    375375                                futex_down(&rcu.sync_lock.futex);
    376376                        } while (rcu.sync_lock.locked);
    377                        
     377
    378378                        list_remove(&blocked_fib.link);
    379379                        rcu.sync_lock.locked = true;
     
    392392{
    393393        assert(rcu.sync_lock.locked);
    394        
     394
    395395        /*
    396396         * Blocked threads have a priority over fibrils when accessing sync().
     
    402402        } else {
    403403                /* Unlock but wake up any fibrils waiting for the lock. */
    404                
     404
    405405                if (!list_empty(&rcu.sync_lock.blocked_fibrils)) {
    406406                        blocked_fibril_t *blocked_fib = member_to_inst(
    407407                                list_first(&rcu.sync_lock.blocked_fibrils), blocked_fibril_t, link);
    408        
     408
    409409                        if (!blocked_fib->is_ready) {
    410410                                blocked_fib->is_ready = true;
     
    412412                        }
    413413                }
    414                
     414
    415415                rcu.sync_lock.locked = false;
    416416                futex_up(&rcu.sync_lock.futex);
     
    432432                thread_usleep(RCU_SLEEP_MS * 1000);
    433433        }
    434                
     434
    435435        futex_down(&rcu.sync_lock.futex);
    436436}
     
    440440{
    441441        size_t nesting_cnt = ACCESS_ONCE(fib->nesting_cnt);
    442        
     442
    443443        return is_in_group(nesting_cnt, group) && is_in_reader_section(nesting_cnt);
    444444}
Note: See TracChangeset for help on using the changeset viewer.