xref: /netbsd-src/share/man/man9/pserialize.9 (revision a536ee5124e62c9a0051a252f7833dc8f50f44c9)
1.\"	$NetBSD: pserialize.9,v 1.3 2011/08/07 12:29:24 rmind Exp $
2.\"
3.\" Copyright (c) 2011 The NetBSD Foundation, Inc.
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
16.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
17.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18.\" PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
19.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25.\" POSSIBILITY OF SUCH DAMAGE.
26.\"
27.Dd July 30, 2011
28.Dt PSERIALIZE 9
29.Os
30.Sh NAME
31.Nm pserialize
32.Nd passive serialization mechanism
33.Sh SYNOPSIS
34.In sys/pserialize.h
35.Ft pserialize_t
36.Fn pserialize_create "void"
37.Ft void
38.Fn pserialize_destroy "pserialize_t psz"
39.Ft int
40.Fn pserialize_read_enter "void"
41.Ft void
42.Fn pserialize_read_exit "int s"
43.Ft void
44.Fn pserialize_perform "pserialize_t psz"
45.\" -----
46.Sh DESCRIPTION
47Passive serialization is a reader / writer synchronisation mechanism
48designed for lock-less read operations.
49The read operations may happen from software interrupt at
50.Dv IPL_SOFTCLOCK .
51.Sh FUNCTIONS
52.Bl -tag -width compact
53.It Fn pserialize_create
54Allocate a new synchronisation object.
55.It Fn pserialize_destroy
56Destroy the synchronisation object.
57No synchronisation activity should happen at this point.
58.It Fn pserialize_read_enter
59Enter the critical path of the reader side.
60Returns an IPL value, which must be passed to
61.Xr pserialize_read_exit 9 .
62Protected code path is not allowed to block.
63.It Fn pserialize_read_exit
64Exit the critical path of the reader side.
65Takes the IPL value returned by
66.Xr pserialize_read_enter 9 .
67.It Fn pserialize_perform
68Perform the passive serialization on the writer side.
69Passing of this function ensures that no readers are in action.
70Writers must be additionally serialized with a separate mechanism,
71e.g.
72.Xr mutex 9 .
73Operation blocks and it may only be performed from thread context.
74.El
75.\" -----
76.Sh EXAMPLES
77Typical code fragment in the writer side:
78.Bd -literal
79	mutex_enter(\*[Am]writer_psz_lock);
80	/*
81	 * Perform the updates (e.g. remove data items from a list).
82	 */
83	...
84	pserialize_perform(object-\*[Gt]psz);
85	/*
86	 * At this point it is safe to destroy old data items.
87	 */
88	mutex_exit(\*[Am]writer_psz_lock);
89.Ed
90.\" -----
91.Sh CODE REFERENCES
92The
93.Nm
94is implemented within the file
95.Pa sys/kern/subr_pserialize.c .
96.Sh SEE ALSO
97.Xr membar_ops 3 ,
98.Xr condvar 9 ,
99.Xr mutex 9 ,
100.Xr rwlock 9
101.Rs
102.%A Hennessy, et al.
103.%T "Passive serialization in a multitasking environment"
104.%I US Patent and Trademark Office
105.%D February 28, 1989
106.%N US Patent 4809168
107.Re
108.Sh HISTORY
109Passive serialization mechanism first appeared in
110.Nx 6.0 .
111