📄 lock.h
字号:
#define LHB_VERSION 6
#endif
#define LHB_PATTERN 123454321
/* Lock header block -- one per lock file, lives up front */
typedef struct lhb {
UCHAR lhb_type; /* memory tag - always type_lbh */
UCHAR lhb_version; /* Version of lock table */
PTR lhb_secondary; /* Secondary lock header block */
PTR lhb_active_owner; /* Active owner, if any */
struct srq lhb_owners; /* Que of active owners */
struct srq lhb_free_owners; /* Free owners blocks */
struct srq lhb_free_locks; /* Free lock blocks */
struct srq lhb_free_requests; /* Free lock requests */
SLONG lhb_length; /* Size of lock table */
SLONG lhb_used; /* Bytes of lock table in use */
USHORT lhb_hash_slots; /* Number of hash slots allocated */
USHORT lhb_flags; /* Miscellaneous info */
#ifdef mpexl
SLONG lhb_mutex [2]; /* Mutex controlling access */
#else
MTX_T lhb_mutex [1]; /* Mutex controlling access */
#endif
PTR lhb_manager; /* Lock manager owner block */
PTR lhb_history;
ULONG lhb_process_count; /* To give a unique id to each process attachment to the lock table */
PTR lhb_mask; /* Semaphore mask block */
ULONG lhb_scan_interval; /* Deadlock scan interval (secs) */
ULONG lhb_acquire_spins;
ULONG lhb_acquires;
ULONG lhb_acquire_blocks;
ULONG lhb_acquire_retries;
ULONG lhb_retry_success;
ULONG lhb_enqs;
ULONG lhb_converts;
ULONG lhb_downgrades;
ULONG lhb_deqs;
ULONG lhb_read_data;
ULONG lhb_write_data;
ULONG lhb_query_data;
ULONG lhb_operations [LCK_MAX_SERIES];
ULONG lhb_waits;
ULONG lhb_denies;
ULONG lhb_timeouts;
ULONG lhb_blocks;
ULONG lhb_direct_sigs;
ULONG lhb_indirect_sigs;
ULONG lhb_wakeups;
ULONG lhb_scans;
ULONG lhb_deadlocks;
ULONG lhb_wait_time;
ULONG lhb_reserved [2]; /* For future use */
struct srq lhb_data [LCK_MAX_SERIES];
struct srq lhb_hash [1]; /* Hash table */
} *LHB;
#define LHB_lock_ordering 1 /* Lock ordering is enabled */
#define LHB_shut_manager 2 /* Lock manager shutdown flag */
/* Secondary header block -- exists only in V3.3 and later lock
managers. It is pointed to by the word in the lhb that used to contain
a pattern. */
typedef struct shb {
UCHAR shb_type; /* memory tag - always type_shb */
UCHAR shb_flags;
PTR shb_history;
PTR shb_remove_node; /* Node removing itself */
PTR shb_insert_que; /* Queue inserting into */
PTR shb_insert_prior; /* Prior of inserting queue */
SLONG shb_misc [10]; /* Unused space */
} *SHB;
/* Lock block */
typedef struct lbl {
UCHAR lbl_type; /* mem tag: type_lbl=in use, type_null=free */
UCHAR lbl_state; /* High state granted */
UCHAR lbl_size; /* Key bytes allocated */
UCHAR lbl_length; /* Key bytes used */
struct srq lbl_requests; /* Requests granted */
struct srq lbl_lhb_hash; /* Collision que for hash table */
struct srq lbl_lhb_data; /* Lock data que by series */
SLONG lbl_data; /* user data */
PTR lbl_parent; /* Parent */
#ifdef NeXT
USHORT lbl_eventcount; /* Lock eventcount */
#endif
UCHAR lbl_series; /* Lock series */
UCHAR lbl_flags; /* Misc flags */
USHORT lbl_pending_lrq_count; /* count of lbl_requests with LRQ_pending */
#ifdef mpexl
UCHAR lbl_counts [LCK_max]; /* Counts of granted locks */
#else
USHORT lbl_counts [LCK_max]; /* Counts of granted locks */
#endif
UCHAR lbl_key [1]; /* Key value */
} *LBL;
/* No flags are defined for LBL at this time */
/* Lock requests */
typedef struct lrq {
UCHAR lrq_type; /* mem tag: type_lrq=in use, type_null=free */
UCHAR lrq_flags; /* Misc crud */
UCHAR lrq_requested; /* Level requested */
UCHAR lrq_state; /* State of lock request */
PTR lrq_owner; /* Owner making request */
PTR lrq_lock; /* Lock requested */
SLONG lrq_data; /* Lock data requested */
struct srq lrq_own_requests; /* Locks granted for owner */
struct srq lrq_lbl_requests; /* Que of requests (active, pending) */
struct srq lrq_own_blocks; /* Owner block que */
int (*lrq_ast_routine)(); /* Block ast routine */
int *lrq_ast_argument; /* Ast argument */
} *LRQ;
#define LRQ_blocking 1 /* Request is blocking */
#define LRQ_pending 2 /* Request is pending */
#define LRQ_converting 4 /* Request is pending conversion */
#define LRQ_rejected 8 /* Request is rejected */
#define LRQ_timed_out 16 /* Wait timed out */
#define LRQ_deadlock 32 /* Request has been seen by the deadlock-walk */
#define LRQ_repost 64 /* Request block used for repost */
#define LRQ_scanned 128 /* Request already scanned for deadlock */
#define LRQ_blocking_seen 256 /* Blocking notification received by owner */
/* Owner block */
typedef struct own {
UCHAR own_type; /* memory tag - always type_own */
UCHAR own_owner_type; /* type of owner */
SSHORT own_count; /* init count for the owner */
ULONG own_owner_id; /* Owner ID */
UATOM own_ast_flags; /* flags shared by main and ast codes */
UATOM own_ast_hung_flags; /* unprotected - OWN_hung flag */
struct srq own_lhb_owners; /* Owner que */
struct srq own_requests; /* Lock requests granted */
struct srq own_blocks; /* Lock requests blocking */
PTR own_pending_request; /* Request we're waiting on */
int own_process_id; /* Owner's process ID */
int own_process_uid; /* Owner's process UID */
ULONG own_acquire_time; /* lhb_acquires when owner last tried acquire() */
ULONG own_acquire_realtime; /* GET_TIME when owner last tried acquire() */
#ifdef mpexl
SLONG own_mpexl_async_port; /* Asynchronous port handle */
SLONG own_mpexl_sync_port; /* Synchronous port handle */
UCHAR own_semaphore; /* Owner semaphore -- see note below */
#else
#ifdef NeXT
struct condition own_NeXT_semaphore; /* Condition variable to wait on */
#endif
#ifdef WIN_NT
void *own_wakeup_hndl; /* Handle of wakeup event */
#ifndef SUPERSERVER
void *own_blocking_hndl; /* Handle of blocking event */
#endif
#endif /* WIN_NT */
#ifdef OS2_ONLY
SLONG own_blocking_hndl; /* Handle of blocking event */
#endif
#ifdef SOLARIS_MT
EVENT_T own_blocking [1]; /* Blocking event block */
EVENT_T own_stall [1]; /* Owner is stalling for other owner */
#endif
#ifndef WIN_NT
EVENT_T own_wakeup [1]; /* Wakeup event block */
#endif
USHORT own_semaphore; /* Owner semaphore -- see note below */
USHORT own_flags; /* Misc stuff */
#endif
} *OWN;
/* Flags in own_flags */
#define OWN_blocking 1 /* Owner is blocking */
#define OWN_scanned 2 /* Owner has been deadlock scanned */
#define OWN_manager 4 /* Owner is privileged manager */
#define OWN_signal 8 /* Owner needs signal delivered */
#define OWN_wakeup 32 /* Owner has been awoken */
#define OWN_starved 128 /* This thread may be starved */
/* Flags in own_ast_flags */
#define OWN_signaled 16 /* Signal is thought to be delivered */
/* Flags in own_semaphore */
#define OWN_semavail 0x8000 /* Process semaphore is available */
/* Flags in own_ast_hung_flag */
#define OWN_hung 64 /* Owner may be hung by OS-level bug */
/* NOTE: own_semaphore, when USE_EVENTS is set, is used to indicate when a
owner is waiting inside wait_for_request(). post_wakeup() will only
attempt to wakeup owners that are waiting. The reason for this is
likely historical - a flag bit could be used for this instead. */
/* Semaphore mask block */
typedef struct smb {
UCHAR smb_type; /* memory tag - always type_smb */
ULONG smb_mask [1]; /* Mask of available semaphores */
} *SMB;
/* Lock manager history block */
typedef struct his {
UCHAR his_type; /* memory tag - always type_his */
UCHAR his_operation; /* operation that occured */
PTR his_next; /* PTR to next item in history list */
PTR his_process; /* owner to record for this operation */
PTR his_lock; /* lock to record for operation */
PTR his_request; /* request to record for operation */
} *HIS;
/* his_operation definitions */
#define his_enq 1
#define his_deq 2
#define his_convert 3
#define his_signal 4
#define his_post_ast 5
#define his_wait 6
#define his_del_process 7
#define his_del_lock 8
#define his_del_request 9
#define his_deny 10
#define his_grant 11
#define his_leave_ast 12
#define his_scan 13
#define his_dead 14
#define his_enter 15
#define his_bug 16
#define his_active 17
#define his_cleanup 18
#define his_del_owner 19
#define his_MAX his_del_owner
#endif /* _ISC_LOCK_LOCK_H_ */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -