MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ck_epoch_synchronize_wait

Function ck_epoch_synchronize_wait

freebsd/contrib/ck/src/ck_epoch.c:424–526  ·  view source on GitHub ↗

* This function must not be called with-in read section. */

Source from the content-addressed store, hash-verified

422 * This function must not be called with-in read section.
423 */
424void
425ck_epoch_synchronize_wait(struct ck_epoch *global,
426 ck_epoch_wait_cb_t *cb, void *ct)
427{
428 struct ck_epoch_record *cr;
429 unsigned int delta, epoch, goal, i;
430 bool active;
431
432 ck_pr_fence_memory();
433
434 /*
435 * The observation of the global epoch must be ordered with respect to
436 * all prior operations. The re-ordering of loads is permitted given
437 * monoticity of global epoch counter.
438 *
439 * If UINT_MAX concurrent mutations were to occur then it is possible
440 * to encounter an ABA-issue. If this is a concern, consider tuning
441 * write-side concurrency.
442 */
443 delta = epoch = ck_pr_load_uint(&global->epoch);
444 goal = epoch + CK_EPOCH_GRACE;
445
446 for (i = 0, cr = NULL; i < CK_EPOCH_GRACE - 1; cr = NULL, i++) {
447 bool r;
448
449 /*
450 * Determine whether all threads have observed the current
451 * epoch with respect to the updates on invocation.
452 */
453 while (cr = ck_epoch_scan(global, cr, delta, &active),
454 cr != NULL) {
455 unsigned int e_d;
456
457 ck_pr_stall();
458
459 /*
460 * Another writer may have already observed a grace
461 * period.
462 */
463 e_d = ck_pr_load_uint(&global->epoch);
464 if (e_d == delta) {
465 epoch_block(global, cr, cb, ct);
466 continue;
467 }
468
469 /*
470 * If the epoch has been updated, we may have already
471 * met our goal.
472 */
473 delta = e_d;
474 if ((goal > epoch) & (delta >= goal))
475 goto leave;
476
477 epoch_block(global, cr, cb, ct);
478
479 /*
480 * If the epoch has been updated, then a grace period
481 * requires that all threads are observed idle at the

Callers 4

ck_epoch_synchronizeFunction · 0.70
ck_epoch_barrier_waitFunction · 0.70
epoch_wait_preemptFunction · 0.50
epoch_waitFunction · 0.50

Calls 3

ck_epoch_scanFunction · 0.85
epoch_blockFunction · 0.85
ck_pr_stallFunction · 0.50

Tested by

no test coverage detected