home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
NeXTSTEP 3.2 (Developer)
/
NS_dev_3.2.iso
/
NextDeveloper
/
Headers
/
kernserv
/
lock.h
< prev
next >
Wrap
Text File
|
1993-10-19
|
2KB
|
85 lines
/*
* Mach Operating System
* Copyright (c) 1989 Carnegie-Mellon University
* Copyright (c) 1988 Carnegie-Mellon University
* Copyright (c) 1987 Carnegie-Mellon University
* All rights reserved. The CMU software License Agreement specifies
* the terms and conditions for use and redistribution.
*/
/*
* HISTORY
* 11-Jul-91 Gregg Kellogg (gk) at NeXT
* Initial version.
*/
/*
* File: kernserv/lock.h
* Author: Avadis Tevanian, Jr., Michael Wayne Young
* Copyright (C) 1985, Avadis Tevanian, Jr., Michael Wayne Young
*
* Exported locking primitives definitions
*
*/
#ifndef _KERN_INTERNAL_LOCK_H_
#define _KERN_INTERNAL_LOCK_H_
#import <mach/boolean.h>
/*
* A simple spin lock.
*/
#import <mach/machine/simple_lock.h>
/*
* The general lock structure. Provides for multiple readers,
* upgrading from read to write, and sleeping until the lock
* can be gained.
*
* On some (many) architectures, assembly language code in the inline
* program fiddles the lock structures. It must be changed in concert
* with the structure layout.
*/
struct lock {
/* Only the "interlock" field is used for hardware exclusion;
* other fields are modified with normal instructions after
* acquiring the interlock bit.
*/
simple_lock_data_t interlock;
unsigned int read_count:16,
want_upgrade:1,
want_write:1,
waiting:1,
can_sleep:1,
recursion_depth:12;
char *thread;
/* Thread that has lock, if recursive locking allowed */
/* (Not thread_t to avoid recursive definitions.) */
};
typedef struct lock lock_data_t;
typedef struct lock *lock_t;
/* Sleep locks must work even if no multiprocessing */
extern lock_t lock_alloc();
extern void lock_free();
extern void lock_init();
extern void lock_sleepable();
extern void lock_write();
extern void lock_read();
extern void lock_done();
extern boolean_t lock_read_to_write();
extern void lock_write_to_read();
extern boolean_t lock_try_write();
extern boolean_t lock_try_read();
extern boolean_t lock_try_read_to_write();
#define lock_read_done(l) lock_done(l)
#define lock_write_done(l) lock_done(l)
extern void lock_set_recursive();
extern void lock_clear_recursive();
#endif _KERN_INTERNAL_LOCK_H_