clockb, cunlockb --
conditionally lock and unlock critical sections
int clockb(struct lockb *lock_xxtab);
void cunlockb(struct lockb *lock_xxtab, int orig_spl);
clockb locks a critical section
on the condition that a lock is not already held.
cunlockb releases a lock pointed to by lock_xxtab
if it was acquired by calling clockb,
but it will not release a lock
acquired by a call to
This restores multiprocessor access.
Pointer to a
original processor level returned by a call to
resets the priority level to this value.
clockb returns the existing processor
level (spl) if the lock is acquired;
-1 if a lock is already held.
cunlockb does not return a value.
can cause the operating system to panic
if one processor holds a lock,
for too long, while another processor is trying to acquire it;
the panic occurs after one million attempts to acquire the lock.
In addition, clockb leaves all interrupts blocked upon
return. The system clock loses time if the
critical code section takes longer than two clock ticks to execute.
Context and synchronization
Non-blockable, interrupt, user, or blockable
2mp, 3, 3mp, 4, 4mp, 5, 5mp, 6, 6mp
SVR5 DDI compatibility
DDI does not support these locking functions,
but provides a different (and richer)
set of locking primitives; see
``Spin locks (DDI)'' in HDK Technical Reference.
``Spin locks (ODDI)'' in HDK Technical Reference
``Critical code section'' in HDK Technical Reference
Use a conditional lock in a function when
it is called by another function which may already have created a lock.
In the following example,
function f3 locks and unlocks a critical section
when called from f2,
but not when called from f1:
Refer to the
man pages for descriptions of ordinary locking of critical sections.
ospl = lockb(&lock_xxtab);
old_spl = clockb(&lock_xxtab);
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005