Synchronization deals with ensuring that data or resource accesses do not occur at the same instant from two or more threads. You must determine whether it is necessary to synchronize access to data. Some memory locations are read-only from the beginning and do not need synchronization. Other locations must be preserved against more than one thread writing to them at the same time. There are also data variables that are changed infrequently.
LibC supports a comprehensive set of synchronization primitives, which were based on an evaluation of the synchronization needs for services that might be ported to LibC and includes interfaces for the following synchronization mechanisms:
Mutually exclusive locks (mutexes)
Reader-writer locks
Condition variables
Semaphores
Barriers
NKS spin locks and barriers are not currently implemented. For NetWare® operating system spin locks, see netware.h.
LibC supports the following synchronization interfaces:
POSIX synchronization functions, commonly called pthreads, supported on most operating systems. The POSIX functions are not available until NetWare 5.1 SP5 and NetWare 6.0 SP2.
UNIX International synchronization functions, commonly called UI, supported by most UNIX operating systems. UI functions are not available until NetWare 5.1 SP5 and NetWare 6.0 SP2.
Novell® Kernel Services (NKS) synchronization functions, supported on NetWare® 5.1 SP4 or later and NetWare 6.0 or later.
System-V semaphores, supported on NetWare 5.1 SP6 or later and NetWare 6.0 SP3 or later. This is the only supported interface that allows you to create a global semaphore that can be shared with multiple applications.
The synchronization interface you select should match the thread interface you select. Novell does not recommend mixing interfaces. For example, you should use NKS synchronization functions with NKS threads rather than pthreads.
This section covers the following topics: