Changeset 3679f51a in mainline for uspace/lib/c/generic/rcu.c
- Timestamp:
- 2018-06-25T20:41:09Z (6 years ago)
- 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)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/rcu.c
rd73d992 r3679f51a 150 150 151 151 152 static void wait_for_readers(size_t reader_group , blocking_mode_t blocking_mode);152 static void wait_for_readers(size_t reader_group); 153 153 static void force_mb_in_all_threads(void); 154 154 static bool is_preexisting_reader(const fibril_rcu_data_t *fib, size_t group); 155 155 156 static void lock_sync( blocking_mode_t blocking_mode);156 static void lock_sync(void); 157 157 static void unlock_sync(void); 158 static void sync_sleep( blocking_mode_t blocking_mode);158 static void sync_sleep(void); 159 159 160 160 static bool is_in_group(size_t nesting_cnt, size_t group); … … 242 242 243 243 /** Blocks until all preexisting readers exit their critical sections. */ 244 void _rcu_synchronize(blocking_mode_t blocking_mode)244 void rcu_synchronize(void) 245 245 { 246 246 assert(!rcu_read_locked()); … … 252 252 size_t gp_in_progress = ACCESS_ONCE(rcu.cur_gp); 253 253 254 lock_sync( blocking_mode);254 lock_sync(); 255 255 256 256 /* … … 300 300 301 301 size_t new_reader_group = get_other_group(rcu.reader_group); 302 wait_for_readers(new_reader_group , blocking_mode);302 wait_for_readers(new_reader_group); 303 303 304 304 /* Separates waiting for readers in new_reader_group from group flip. */ … … 312 312 memory_barrier(); 313 313 314 wait_for_readers(old_reader_group , blocking_mode);314 wait_for_readers(old_reader_group); 315 315 316 316 /* MB_FORCE_U */ … … 332 332 333 333 /** Waits for readers of reader_group to exit their readers sections. */ 334 static void wait_for_readers(size_t reader_group , blocking_mode_t blocking_mode)334 static void wait_for_readers(size_t reader_group) 335 335 { 336 336 futex_down(&rcu.list_futex); … … 346 346 if (is_preexisting_reader(fib, reader_group)) { 347 347 futex_up(&rcu.list_futex); 348 sync_sleep( blocking_mode);348 sync_sleep(); 349 349 futex_down(&rcu.list_futex); 350 350 /* Break to while loop. */ … … 361 361 } 362 362 363 static void lock_sync( blocking_mode_t blocking_mode)363 static void lock_sync(void) 364 364 { 365 365 futex_down(&rcu.sync_lock.futex); 366 366 if (rcu.sync_lock.locked) { 367 if (blocking_mode == BM_BLOCK_FIBRIL) { 368 blocked_fibril_t blocked_fib; 369 blocked_fib.id = fibril_get_id(); 370 371 list_append(&blocked_fib.link, &rcu.sync_lock.blocked_fibrils); 372 373 do { 374 blocked_fib.is_ready = false; 375 futex_up(&rcu.sync_lock.futex); 376 fibril_switch(FIBRIL_TO_MANAGER); 377 futex_down(&rcu.sync_lock.futex); 378 } while (rcu.sync_lock.locked); 379 380 list_remove(&blocked_fib.link); 381 rcu.sync_lock.locked = true; 382 } else { 383 assert(blocking_mode == BM_BLOCK_THREAD); 384 rcu.sync_lock.blocked_thread_cnt++; 367 blocked_fibril_t blocked_fib; 368 blocked_fib.id = fibril_get_id(); 369 370 list_append(&blocked_fib.link, &rcu.sync_lock.blocked_fibrils); 371 372 do { 373 blocked_fib.is_ready = false; 385 374 futex_up(&rcu.sync_lock.futex); 386 futex_down(&rcu.sync_lock.futex_blocking_threads); 387 } 375 fibril_switch(FIBRIL_TO_MANAGER); 376 futex_down(&rcu.sync_lock.futex); 377 } while (rcu.sync_lock.locked); 378 379 list_remove(&blocked_fib.link); 380 rcu.sync_lock.locked = true; 388 381 } else { 389 382 rcu.sync_lock.locked = true; … … 420 413 } 421 414 422 static void sync_sleep( blocking_mode_t blocking_mode)415 static void sync_sleep(void) 423 416 { 424 417 assert(rcu.sync_lock.locked); … … 428 421 */ 429 422 futex_up(&rcu.sync_lock.futex); 430 431 if (blocking_mode == BM_BLOCK_FIBRIL) { 432 async_usleep(RCU_SLEEP_MS * 1000); 433 } else { 434 thread_usleep(RCU_SLEEP_MS * 1000); 435 } 436 423 async_usleep(RCU_SLEEP_MS * 1000); 437 424 futex_down(&rcu.sync_lock.futex); 438 425 }
Note:
See TracChangeset
for help on using the changeset viewer.