Invalidation of synchronization mechanisms
The syntax of the functions that invalidate synchronization structures
is even more regular than that of the initializing functions.
-
The first and only argument is a pointer to the mechanism-specific structure
to be invalidated.
The syntax is:
int sema_destroy( sema_t *sema);
int _spin_destroy( spin_t *lock);
int barrier_destroy( barrier_t *barrier);
int _barrier_spin_destroy(barrier_spin_t *barrier);
int cond_destroy( cond_t *cond);
int mutex_destroy( mutex_t *mutex);
int rmutex_destroy( rmutex_t *rmutex);
int rwlock_destroy( rwlock_t *rwlock);
Each function can fail as follows:
EINVAL-
Invalid argument specified.
EBUSY-
Mechanism currently in use.
The effect of these functions is:
-
To mark the structure as being invalid for further use
(unless re-initialized).
-
To allow the recovery of any Threads Library internal
resources that may have been allocated when the synchronization mechanism
was initialized.
-
Though these _destroy functions recover underlying resources,
the space for the synchronization structure itself remains.
If the space is to be recovered
(say the structure will no longer be used)
that must be done separately.
For example,
a space acquired from
malloc(S)
should be recovered with free
(see
malloc(S)).
Next topic:
Compilation environment
Previous topic:
Alternative initialization
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 -- 02 June 2005