111 lines
3.6 KiB
Groff
111 lines
3.6 KiB
Groff
.\" $NetBSD: pserialize.9,v 1.3 2011/08/07 12:29:24 rmind Exp $
|
|
.\"
|
|
.\" Copyright (c) 2011 The NetBSD Foundation, Inc.
|
|
.\" All rights reserved.
|
|
.\"
|
|
.\" Redistribution and use in source and binary forms, with or without
|
|
.\" modification, are permitted provided that the following conditions
|
|
.\" are met:
|
|
.\" 1. Redistributions of source code must retain the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer.
|
|
.\" 2. Redistributions in binary form must reproduce the above copyright
|
|
.\" notice, this list of conditions and the following disclaimer in the
|
|
.\" documentation and/or other materials provided with the distribution.
|
|
.\"
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
.\" POSSIBILITY OF SUCH DAMAGE.
|
|
.\"
|
|
.Dd July 30, 2011
|
|
.Dt PSERIALIZE 9
|
|
.Os
|
|
.Sh NAME
|
|
.Nm pserialize
|
|
.Nd passive serialization mechanism
|
|
.Sh SYNOPSIS
|
|
.In sys/pserialize.h
|
|
.Ft pserialize_t
|
|
.Fn pserialize_create "void"
|
|
.Ft void
|
|
.Fn pserialize_destroy "pserialize_t psz"
|
|
.Ft int
|
|
.Fn pserialize_read_enter "void"
|
|
.Ft void
|
|
.Fn pserialize_read_exit "int s"
|
|
.Ft void
|
|
.Fn pserialize_perform "pserialize_t psz"
|
|
.\" -----
|
|
.Sh DESCRIPTION
|
|
Passive serialization is a reader / writer synchronisation mechanism
|
|
designed for lock-less read operations.
|
|
The read operations may happen from software interrupt at
|
|
.Dv IPL_SOFTCLOCK .
|
|
.Sh FUNCTIONS
|
|
.Bl -tag -width compact
|
|
.It Fn pserialize_create
|
|
Allocate a new synchronisation object.
|
|
.It Fn pserialize_destroy
|
|
Destroy the synchronisation object.
|
|
No synchronisation activity should happen at this point.
|
|
.It Fn pserialize_read_enter
|
|
Enter the critical path of the reader side.
|
|
Returns an IPL value, which must be passed to
|
|
.Xr pserialize_read_exit 9 .
|
|
Protected code path is not allowed to block.
|
|
.It Fn pserialize_read_exit
|
|
Exit the critical path of the reader side.
|
|
Takes the IPL value returned by
|
|
.Xr pserialize_read_enter 9 .
|
|
.It Fn pserialize_perform
|
|
Perform the passive serialization on the writer side.
|
|
Passing of this function ensures that no readers are in action.
|
|
Writers must be additionally serialized with a separate mechanism,
|
|
e.g.
|
|
.Xr mutex 9 .
|
|
Operation blocks and it may only be performed from thread context.
|
|
.El
|
|
.\" -----
|
|
.Sh EXAMPLES
|
|
Typical code fragment in the writer side:
|
|
.Bd -literal
|
|
mutex_enter(\*[Am]writer_psz_lock);
|
|
/*
|
|
* Perform the updates (e.g. remove data items from a list).
|
|
*/
|
|
...
|
|
pserialize_perform(object-\*[Gt]psz);
|
|
/*
|
|
* At this point it is safe to destroy old data items.
|
|
*/
|
|
mutex_exit(\*[Am]writer_psz_lock);
|
|
.Ed
|
|
.\" -----
|
|
.Sh CODE REFERENCES
|
|
The
|
|
.Nm
|
|
is implemented within the file
|
|
.Pa sys/kern/subr_pserialize.c .
|
|
.Sh SEE ALSO
|
|
.Xr membar_ops 3 ,
|
|
.Xr condvar 9 ,
|
|
.Xr mutex 9 ,
|
|
.Xr rwlock 9
|
|
.Rs
|
|
.%A Hennessy, et al.
|
|
.%T "Passive serialization in a multitasking environment"
|
|
.%I US Patent and Trademark Office
|
|
.%D February 28, 1989
|
|
.%N US Patent 4809168
|
|
.Re
|
|
.Sh HISTORY
|
|
Passive serialization mechanism first appeared in
|
|
.Nx 6.0 .
|