| 1 |
.\" |
| 2 |
.\" Copyright 2012-2013 Samy Al Bahra. |
| 3 |
.\" All rights reserved. |
| 4 |
.\" |
| 5 |
.\" Redistribution and use in source and binary forms, with or without |
| 6 |
.\" modification, are permitted provided that the following conditions |
| 7 |
.\" are met: |
| 8 |
.\" 1. Redistributions of source code must retain the above copyright |
| 9 |
.\" notice, this list of conditions and the following disclaimer. |
| 10 |
.\" 2. Redistributions in binary form must reproduce the above copyright |
| 11 |
.\" notice, this list of conditions and the following disclaimer in the |
| 12 |
.\" documentation and/or other materials provided with the distribution. |
| 13 |
.\" |
| 14 |
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
| 15 |
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 16 |
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 17 |
.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
| 18 |
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 19 |
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
| 20 |
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
| 21 |
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
| 22 |
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
| 23 |
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 24 |
.\" SUCH DAMAGE. |
| 25 |
.\" |
| 26 |
.\" |
| 27 |
.Dd September 2, 2012 |
| 28 |
.Dt CK_EPOCH_SYNCHRONIZE 3 |
| 29 |
.Sh NAME |
| 30 |
.Nm ck_epoch_synchronize |
| 31 |
.Nd block until a grace period has been detected |
| 32 |
.Sh LIBRARY |
| 33 |
Concurrency Kit (libck, \-lck) |
| 34 |
.Sh SYNOPSIS |
| 35 |
.In ck_epoch.h |
| 36 |
.Ft void |
| 37 |
.Fn ck_epoch_synchronize "ck_epoch_record_t *record" |
| 38 |
.Sh DESCRIPTION |
| 39 |
The |
| 40 |
.Fn ck_epoch_synchronize 3 |
| 41 |
function will block the caller until a grace period has been |
| 42 |
detected, according to the semantics of epoch reclamation. |
| 43 |
It is not safe to call this function on a record that is |
| 44 |
in an active section. |
| 45 |
Any objects requiring safe memory reclamation which are logically |
| 46 |
deleted are safe for physical deletion following a call to |
| 47 |
.Fn ck_epoch_synchronize 3 . |
| 48 |
If you require that all callbacks be dispatched, then it is suggested |
| 49 |
that you use |
| 50 |
.Fn ck_epoch_barrier 3 |
| 51 |
instead or follow a call of |
| 52 |
.Fn ck_epoch_synchronize 3 |
| 53 |
with |
| 54 |
.Fn ck_epoch_reclaim 3 . |
| 55 |
.Sh EXAMPLE |
| 56 |
.Bd -literal -offset indent |
| 57 |
|
| 58 |
#include <ck_epoch.h> |
| 59 |
#include <ck_stack.h> |
| 60 |
#include <stdlib.h> |
| 61 |
|
| 62 |
/* |
| 63 |
* epoch was previously initialized with ck_epoch_init. |
| 64 |
* stack was previously initialized with ck_stack_init. |
| 65 |
*/ |
| 66 |
ck_epoch_t *epoch; |
| 67 |
ck_stack_t *stack; |
| 68 |
|
| 69 |
void |
| 70 |
function(void) |
| 71 |
{ |
| 72 |
ck_epoch_record_t *record; |
| 73 |
ck_stack_entry_t *s; |
| 74 |
|
| 75 |
record = malloc(sizeof *record); |
| 76 |
ck_epoch_register(&epoch, record, NULL); |
| 77 |
|
| 78 |
/* |
| 79 |
* We are using an epoch section here to guarantee no |
| 80 |
* nodes in the stack are deleted while we are dereferencing |
| 81 |
* them. This is needed here because there are multiple writers. |
| 82 |
* If there was only one thread popping from the this stack, |
| 83 |
* then there is no need to ck_epoch_begin/ck_epoch_end. |
| 84 |
*/ |
| 85 |
ck_epoch_begin(record); |
| 86 |
|
| 87 |
/* Logically delete an object. */ |
| 88 |
s = ck_stack_pop_upmc(stack); |
| 89 |
|
| 90 |
ck_epoch_end(record); |
| 91 |
|
| 92 |
/* |
| 93 |
* Wait until no threads could possibly have a reference to the |
| 94 |
* object we just popped (assume all threads are simply executing |
| 95 |
* ck_stack_pop_upmc). |
| 96 |
*/ |
| 97 |
ck_epoch_synchronize(record); |
| 98 |
|
| 99 |
/* It is now safe to physically delete the object. */ |
| 100 |
free(s); |
| 101 |
return; |
| 102 |
} |
| 103 |
.Ed |
| 104 |
.Sh RETURN VALUES |
| 105 |
This function has no return value. |
| 106 |
.Sh ERRORS |
| 107 |
The object pointed to by .Fa record must have been previously registered via |
| 108 |
.Fn ck_epoch_register 3 . |
| 109 |
.Sh SEE ALSO |
| 110 |
.Xr ck_epoch_init 3 , |
| 111 |
.Xr ck_epoch_register 3 , |
| 112 |
.Xr ck_epoch_unregister 3 , |
| 113 |
.Xr ck_epoch_recycle 3 , |
| 114 |
.Xr ck_epoch_poll 3 , |
| 115 |
.Xr ck_epoch_reclaim 3 , |
| 116 |
.Xr ck_epoch_barrier 3 , |
| 117 |
.Xr ck_epoch_call 3 , |
| 118 |
.Xr ck_epoch_begin 3 , |
| 119 |
.Xr ck_epoch_end 3 |
| 120 |
.Pp |
| 121 |
Additional information available at http://concurrencykit.org/ |