Deleted Added
full compact
lock.h (66354) lock.h (66615)
1/*
2 * Copyright (c) 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code contains ideas from software contributed to Berkeley by
6 * Avadis Tevanian, Jr., Michael Wayne Young, and the Mach Operating
7 * System project at Carnegie-Mellon University.
8 *

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

30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)lock.h 8.12 (Berkeley) 5/19/95
1/*
2 * Copyright (c) 1995
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code contains ideas from software contributed to Berkeley by
6 * Avadis Tevanian, Jr., Michael Wayne Young, and the Mach Operating
7 * System project at Carnegie-Mellon University.
8 *

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

30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * @(#)lock.h 8.12 (Berkeley) 5/19/95
38 * $FreeBSD: head/sys/sys/lock.h 66354 2000-09-25 15:04:15Z bp $
38 * $FreeBSD: head/sys/sys/lock.h 66615 2000-10-04 01:29:17Z jasone $
39 */
40
41#ifndef _LOCK_H_
42#define _LOCK_H_
43
39 */
40
41#ifndef _LOCK_H_
42#define _LOCK_H_
43
44
45#include <machine/lock.h>
44#include <machine/lock.h>
45#include <machine/mutex.h>
46
47/*
48 * The general lock structure. Provides for multiple shared locks,
49 * upgrading from shared to exclusive, and sleeping until the lock
50 * can be gained. The simple locks are defined in <machine/param.h>.
51 */
52struct lock {
46
47/*
48 * The general lock structure. Provides for multiple shared locks,
49 * upgrading from shared to exclusive, and sleeping until the lock
50 * can be gained. The simple locks are defined in <machine/param.h>.
51 */
52struct lock {
53 struct simplelock lk_interlock; /* lock on remaining fields */
53 struct mtx lk_interlock; /* lock on remaining fields */
54 struct mtxf lk_pad; /* padding to keep sizeof constant */
54 u_int lk_flags; /* see below */
55 int lk_sharecount; /* # of accepted shared locks */
56 int lk_waitcount; /* # of processes sleeping for lock */
57 short lk_exclusivecount; /* # of recursive exclusive locks */
58 short lk_prio; /* priority at which to sleep */
59 char *lk_wmesg; /* resource sleeping (for tsleep) */
60 int lk_timo; /* maximum sleep time (for tsleep) */
61 pid_t lk_lockholder; /* pid of exclusive lock holder */

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

127 *
128 * These flags are used internally to the lock manager.
129 */
130#define LK_WANT_UPGRADE 0x00000100 /* waiting for share-to-excl upgrade */
131#define LK_WANT_EXCL 0x00000200 /* exclusive lock sought */
132#define LK_HAVE_EXCL 0x00000400 /* exclusive lock obtained */
133#define LK_WAITDRAIN 0x00000800 /* process waiting for lock to drain */
134#define LK_DRAINING 0x00004000 /* lock is being drained */
55 u_int lk_flags; /* see below */
56 int lk_sharecount; /* # of accepted shared locks */
57 int lk_waitcount; /* # of processes sleeping for lock */
58 short lk_exclusivecount; /* # of recursive exclusive locks */
59 short lk_prio; /* priority at which to sleep */
60 char *lk_wmesg; /* resource sleeping (for tsleep) */
61 int lk_timo; /* maximum sleep time (for tsleep) */
62 pid_t lk_lockholder; /* pid of exclusive lock holder */

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

128 *
129 * These flags are used internally to the lock manager.
130 */
131#define LK_WANT_UPGRADE 0x00000100 /* waiting for share-to-excl upgrade */
132#define LK_WANT_EXCL 0x00000200 /* exclusive lock sought */
133#define LK_HAVE_EXCL 0x00000400 /* exclusive lock obtained */
134#define LK_WAITDRAIN 0x00000800 /* process waiting for lock to drain */
135#define LK_DRAINING 0x00004000 /* lock is being drained */
136#define LK_VALID 0x00008000 /*
137 * Lock is initialized. This is a
138 * temporary hack to support vfs
139 * layering.
140 */
135/*
136 * Control flags
137 *
138 * Non-persistent external flags.
139 */
141/*
142 * Control flags
143 *
144 * Non-persistent external flags.
145 */
140#define LK_INTERLOCK 0x00010000 /* unlock passed simple lock after
141 getting lk_interlock */
146#define LK_INTERLOCK 0x00010000 /*
147 * unlock passed mutex after getting
148 * lk_interlock
149 */
142#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */
143#define LK_NOOBJ 0x00040000 /* vget: don't create object */
144#define LK_THISLAYER 0x00080000 /* vn_lock: lock/unlock only current layer */
145
146/*
147 * Internal state flags corresponding to lk_sharecount, and lk_waitcount
148 */
149#define LK_SHARE_NONZERO 0x00100000

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

172#define LK_KERNPROC ((pid_t) -2)
173#define LK_NOPROC ((pid_t) -1)
174
175void dumplockinfo(struct lock *lkp);
176struct proc;
177
178void lockinit __P((struct lock *, int prio, char *wmesg, int timo,
179 int flags));
150#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */
151#define LK_NOOBJ 0x00040000 /* vget: don't create object */
152#define LK_THISLAYER 0x00080000 /* vn_lock: lock/unlock only current layer */
153
154/*
155 * Internal state flags corresponding to lk_sharecount, and lk_waitcount
156 */
157#define LK_SHARE_NONZERO 0x00100000

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

180#define LK_KERNPROC ((pid_t) -2)
181#define LK_NOPROC ((pid_t) -1)
182
183void dumplockinfo(struct lock *lkp);
184struct proc;
185
186void lockinit __P((struct lock *, int prio, char *wmesg, int timo,
187 int flags));
188void lockdestroy __P((struct lock *));
189
180#ifdef DEBUG_LOCKS
181int debuglockmgr __P((struct lock *, u_int flags,
190#ifdef DEBUG_LOCKS
191int debuglockmgr __P((struct lock *, u_int flags,
182 struct simplelock *, struct proc *p,
192 struct mtx *, struct proc *p,
183 const char *,
184 const char *,
185 int));
186#define lockmgr(lockp, flags, slockp, proc) \
187 debuglockmgr((lockp), (flags), (slockp), (proc), \
188 "lockmgr", __FILE__, __LINE__)
189#else
190int lockmgr __P((struct lock *, u_int flags,
193 const char *,
194 const char *,
195 int));
196#define lockmgr(lockp, flags, slockp, proc) \
197 debuglockmgr((lockp), (flags), (slockp), (proc), \
198 "lockmgr", __FILE__, __LINE__)
199#else
200int lockmgr __P((struct lock *, u_int flags,
191 struct simplelock *, struct proc *p));
201 struct mtx *, struct proc *p));
192#endif
193void lockmgr_printinfo __P((struct lock *));
194int lockstatus __P((struct lock *, struct proc *));
195int lockcount __P((struct lock *));
196
197#ifdef SIMPLELOCK_DEBUG
198void _simple_unlock __P((struct simplelock *alp, const char *, int));
199#define simple_unlock(alp) _simple_unlock(alp, __FILE__, __LINE__)

--- 16 unchanged lines hidden ---
202#endif
203void lockmgr_printinfo __P((struct lock *));
204int lockstatus __P((struct lock *, struct proc *));
205int lockcount __P((struct lock *));
206
207#ifdef SIMPLELOCK_DEBUG
208void _simple_unlock __P((struct simplelock *alp, const char *, int));
209#define simple_unlock(alp) _simple_unlock(alp, __FILE__, __LINE__)

--- 16 unchanged lines hidden ---