DOC HOME SITE MAP MAN PAGES GNU INFO SEARCH PRINT BOOK
 
Threads

Initialization of synchronization mechanisms

Some general characteristics of the initialization functions are:

The syntax of these functions is given below.

   int sema_init(		sema_t		*sema,	int count,	int type,	void *arg);
   int barrier_init(		barrier_t		*barrier,	int count,	int type,	void *arg);
   int _barrier_spin_init(	barrier_spin_t	*barrier,	int count,		void *arg);
   int _spin_init(		spin_t		*lock,			void *arg);
   int cond_init(		cond_t		*cond,		int type,	void *arg);
   int mutex_init(		mutex_t		*mutex,		int type,	void *arg);
   int rmutex_init(		rmutex_t		*rmutex,		int type,	void *arg);
   int rwlock_init(		rwlock_t		*rwlock,		int type,	void *arg);

Alternative initialization

In this implementation, it is valid to use statically initialized (zero-filled) data structures for the synchronization mechanisms.

For most of the mechanisms, a zero-filled data structure is taken to be unlocked and of type USYNC_THREAD. The mechanisms that take a count argument have the following additional interpretations:

Filling the data structure with zeroes is not recommended for re-initialization of synchronization structures. In general, it is incorrect to re-initialize a synchronization structure while in use. Some of the initialization functions (shown above) return EBUSY if called for an active data structure (one on which threads are blocked). Zero-filling the data structure bypasses that check.
Next topic: Invalidation of synchronization mechanisms
Previous topic: Further considerations for synchronization mechanisms

© 2004 The SCO Group, Inc. All rights reserved.
UnixWare 7 Release 7.1.4 - 27 April 2004