summaryrefslogtreecommitdiffstats
path: root/upstream/mageia-cauldron/man9/sleep_on.9
blob: ec19865ca5035749419d6bee761ec0eea0b226d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
.\" -*- nroff -*-
.\"
.\" copyright (C) 1997 Stephen Williams <steve@icarus.com>
.\"
.\" Permission is granted to make and distribute verbatim copies of this
.\" manual provided the copyright notice and this permission notice are
.\" preserved on all copies.
.\"
.\" Permission is granted to copy and distribute modified versions of this
.\" manual under the conditions for verbatim copying, provided that the
.\" entire resulting derived work is distributed under the terms of a
.\" permission notice identical to this one
.\" 
.\" Since the Linux kernel and libraries are constantly changing, this
.\" manual page may be incorrect or out-of-date.  The author(s) assume no
.\" responsibility for errors or omissions, or for damages resulting from
.\" the use of the information contained herein.  The author(s) may not
.\" have taken the same level of care in the production of this manual,
.\" which is licensed free of charge, as they might when working
.\" professionally.
.\" 
.\" Formatted or processed versions of this manual, if unaccompanied by
.\" the source, must acknowledge the copyright and authors of this work.
.\"
.TH sleep_on 9 "$Date:$" "Linux DDI" "Kernel Functions"
.\"
.\" Turn off hyphenation and right justification for the first sections.
.hlm 0
.na
.\" The name should be formatted this way for apropos to work
.SH NAME
sleep_on \- synchronization using a condition variable
.\"
.\"
.SH SYNOPSIS
.B #include <linux/sched.h>
.HP
.BI "void sleep_on(struct\ wait_queue**" condition ")"
.\"
.\" Turn hyphenation and adjustment back on.
.hlm 1
.ad
.SH DESCRIPTION
The
.B sleep_on
function provides a means for synchronizing between processes and
with interrupt handlers. The
.I condition
parameter is a pointer to a pointer to the opaque wait_queue
type. Initialize the condition variable to zero, then pass a pointer
to it to the
.B sleep_on
function. The basic idea is as follows:
.PP
.na
struct wait_queue*con = 0;
.br
	[...]
.br
sleep_on(&con);
.ad
.PP
While a process is sleeping, it is fully interruptible, no matter what
the cpu state when entering the function. The cpu state is restored on
being awakened.
.PP
If a null(0) is passed to
.BR sleep_on ,
it returns immediately, without sleeping. This is a no-op.
.SH "RETURN VALUE"
The
.B sleep_on
function only returns when explicitly awakened.
.SH AVAILABILITY
Linux 1+
.SH "SEE ALSO"
.hlm 0
.na
.BR wake_up "(9)"
.ad
.hlm 1
.PP
.I "/usr/src/linux/kernel/sched.c"
.SH AUTHOR
Stephen Williams <steve@icarus.com>
.SH BUGS
A call to
.I "sleep_on(0)"
seems like an interesting way to test for and momentarily allow
interrupts, but that is not what happens.
.PP
The
.B sleep_on
function cannot be called by interrupt handlers.
.PP
The function is not atomic with the condition tests that the driver
writer might include, so the code executing the
.B sleep_on
function is protected from interrupts. Failure to do so generally
leads to race conditions.