Deleted Added
full compact
sleepqueue.h (134013) sleepqueue.h (136445)
1/*
2 * Copyright (c) 2004 John Baldwin <jhb@FreeBSD.org>
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

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
1/*
2 * Copyright (c) 2004 John Baldwin <jhb@FreeBSD.org>
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

--- 12 unchanged lines hidden (view full) ---

21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD: head/sys/sys/sleepqueue.h 134013 2004-08-19 11:31:42Z jhb $
29 * $FreeBSD: head/sys/sys/sleepqueue.h 136445 2004-10-12 18:36:20Z jhb $
30 */
31
32#ifndef _SYS_SLEEPQUEUE_H_
33#define _SYS_SLEEPQUEUE_H_
34
35/*
36 * Sleep queue interface. Sleep/wakeup and condition variables use a sleep
37 * queue for the queue of threads blocked on a sleep channel.
38 *
30 */
31
32#ifndef _SYS_SLEEPQUEUE_H_
33#define _SYS_SLEEPQUEUE_H_
34
35/*
36 * Sleep queue interface. Sleep/wakeup and condition variables use a sleep
37 * queue for the queue of threads blocked on a sleep channel.
38 *
39 * A thread calls sleepq_lookup() to look up the proper sleep queue in the
40 * hash table that is associated with a specified wait channel. This
41 * function returns a pointer to the queue and locks the associated sleep
42 * queue chain. A thread calls sleepq_add() to add themself onto a sleep
43 * queue and calls one of the sleepq_wait() functions to actually go to
44 * sleep. If a thread needs to abort a sleep operation it should call
45 * sleepq_release() to unlock the associated sleep queue chain lock. If
46 * the thread also needs to remove itself from a queue it just enqueued
47 * itself on, it can use sleepq_remove().
39 * A thread calls sleepq_lock() to lock the sleep queue chain associated
40 * with a given wait channel. A thread can then call call sleepq_add() to
41 * add themself onto a sleep queue and call one of the sleepq_wait()
42 * functions to actually go to sleep. If a thread needs to abort a sleep
43 * operation it should call sleepq_release() to unlock the associated sleep
44 * queue chain lock. If the thread also needs to remove itself from a queue
45 * it just enqueued itself on, it can use sleepq_remove() instead.
48 *
49 * If the thread only wishes to sleep for a limited amount of time, it can
50 * call sleepq_set_timeout() after sleepq_add() to setup a timeout. It
51 * should then use one of the sleepq_timedwait() functions to block.
52 *
53 * If the thread wants to the sleep to be interruptible by signals, it can
54 * call sleepq_catch_signals() after sleepq_add(). It should then use
55 * one of the sleepq_wait_sig() functions to block. After the thread has
56 * been resumed, it should call sleepq_calc_signal_retval() to determine
57 * if it should return EINTR or ERESTART passing in the value returned from
58 * the earlier call to sleepq_catch_signals().
59 *
60 * A thread is normally resumed from a sleep queue by either the
61 * sleepq_signal() or sleepq_broadcast() functions. Sleepq_signal() wakes
62 * the thread with the highest priority that is sleeping on the specified
63 * wait channel. Sleepq_broadcast() wakes all threads that are sleeping
64 * on the specified wait channel. A thread sleeping in an interruptible
65 * sleep can be interrupted by calling sleepq_abort(). A thread can also
66 * be removed from a specified sleep queue using the sleepq_remove()
46 *
47 * If the thread only wishes to sleep for a limited amount of time, it can
48 * call sleepq_set_timeout() after sleepq_add() to setup a timeout. It
49 * should then use one of the sleepq_timedwait() functions to block.
50 *
51 * If the thread wants to the sleep to be interruptible by signals, it can
52 * call sleepq_catch_signals() after sleepq_add(). It should then use
53 * one of the sleepq_wait_sig() functions to block. After the thread has
54 * been resumed, it should call sleepq_calc_signal_retval() to determine
55 * if it should return EINTR or ERESTART passing in the value returned from
56 * the earlier call to sleepq_catch_signals().
57 *
58 * A thread is normally resumed from a sleep queue by either the
59 * sleepq_signal() or sleepq_broadcast() functions. Sleepq_signal() wakes
60 * the thread with the highest priority that is sleeping on the specified
61 * wait channel. Sleepq_broadcast() wakes all threads that are sleeping
62 * on the specified wait channel. A thread sleeping in an interruptible
63 * sleep can be interrupted by calling sleepq_abort(). A thread can also
64 * be removed from a specified sleep queue using the sleepq_remove()
67 * function.
65 * function. Note that the sleep queue chain must first be locked via
66 * sleepq_lock() when calling sleepq_signal() and sleepq_broadcast().
68 *
69 * Each thread allocates a sleep queue at thread creation via sleepq_alloc()
70 * and releases it at thread destruction via sleepq_free(). Note that
71 * a sleep queue is not tied to a specific thread and that the sleep queue
72 * released at thread destruction may not be the same sleep queue that the
73 * thread allocated when it was created.
74 *
75 * XXX: Some other parts of the kernel such as ithread sleeping may end up

--- 8 unchanged lines hidden (view full) ---

84
85#define SLEEPQ_TYPE 0x0ff /* Mask of sleep queue types. */
86#define SLEEPQ_MSLEEP 0x00 /* Used by msleep/wakeup. */
87#define SLEEPQ_CONDVAR 0x01 /* Used for a cv. */
88#define SLEEPQ_INTERRUPTIBLE 0x100 /* Sleep is interruptible. */
89
90void init_sleepqueues(void);
91void sleepq_abort(struct thread *td);
67 *
68 * Each thread allocates a sleep queue at thread creation via sleepq_alloc()
69 * and releases it at thread destruction via sleepq_free(). Note that
70 * a sleep queue is not tied to a specific thread and that the sleep queue
71 * released at thread destruction may not be the same sleep queue that the
72 * thread allocated when it was created.
73 *
74 * XXX: Some other parts of the kernel such as ithread sleeping may end up

--- 8 unchanged lines hidden (view full) ---

83
84#define SLEEPQ_TYPE 0x0ff /* Mask of sleep queue types. */
85#define SLEEPQ_MSLEEP 0x00 /* Used by msleep/wakeup. */
86#define SLEEPQ_CONDVAR 0x01 /* Used for a cv. */
87#define SLEEPQ_INTERRUPTIBLE 0x100 /* Sleep is interruptible. */
88
89void init_sleepqueues(void);
90void sleepq_abort(struct thread *td);
92void sleepq_add(struct sleepqueue *, void *, struct mtx *, const char *,
93 int);
91void sleepq_add(void *, struct mtx *, const char *, int);
94struct sleepqueue *sleepq_alloc(void);
95void sleepq_broadcast(void *, int, int);
96int sleepq_calc_signal_retval(int sig);
97int sleepq_catch_signals(void *wchan);
98void sleepq_free(struct sleepqueue *);
92struct sleepqueue *sleepq_alloc(void);
93void sleepq_broadcast(void *, int, int);
94int sleepq_calc_signal_retval(int sig);
95int sleepq_catch_signals(void *wchan);
96void sleepq_free(struct sleepqueue *);
97void sleepq_lock(void *);
99struct sleepqueue *sleepq_lookup(void *);
100void sleepq_release(void *);
101void sleepq_remove(struct thread *, void *);
102void sleepq_signal(void *, int, int);
103void sleepq_set_timeout(void *wchan, int timo);
104int sleepq_timedwait(void *wchan);
105int sleepq_timedwait_sig(void *wchan, int signal_caught);
106void sleepq_wait(void *);
107int sleepq_wait_sig(void *wchan);
108
109#endif /* _KERNEL */
110#endif /* !_SYS_SLEEPQUEUE_H_ */
98struct sleepqueue *sleepq_lookup(void *);
99void sleepq_release(void *);
100void sleepq_remove(struct thread *, void *);
101void sleepq_signal(void *, int, int);
102void sleepq_set_timeout(void *wchan, int timo);
103int sleepq_timedwait(void *wchan);
104int sleepq_timedwait_sig(void *wchan, int signal_caught);
105void sleepq_wait(void *);
106int sleepq_wait_sig(void *wchan);
107
108#endif /* _KERNEL */
109#endif /* !_SYS_SLEEPQUEUE_H_ */