DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
SCO OpenServer

clockb(D3oddi)


clockb, cunlockb -- conditionally lock and unlock critical sections

Syntax

   #include <sys/ci/cilock.h>
   

int clockb(struct lockb *lock_xxtab);

void cunlockb(struct lockb *lock_xxtab, int orig_spl);

Description

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 lockb(D3oddi). This restores multiprocessor access.

Arguments


lock_xxtab
Pointer to a lockb(D4oddi) structure.

orig_spl
original processor level returned by a call to clockb; see spl(D3oddi). cunlockb( ) resets the priority level to this value.

Return values

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.

Usage

clockb( ) 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 context.

Hardware applicability

All

Version applicability

oddi: 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.

References

ilockb(D3oddi), lockb(D3oddi), spl(D3oddi)

``Spin locks (ODDI)'' in HDK Technical Reference
``Critical code section'' in HDK Technical Reference

Examples

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:
   

f1() { ospl = lockb(&lock_xxtab); f3(); unlockb(&lock_xxtab, ospl); }

f2() { f3(); }

f3() { old_spl = clockb(&lock_xxtab); . . . cunlockb(&lock_xxtab, old_spl); }

Refer to the lockb(D3oddi) and ilockb(D3oddi) man pages for descriptions of ordinary locking of critical sections.
19 June 2005
© 2005 The SCO Group, Inc. All rights reserved.
OpenServer 5 HDK - June 2005