pthread_spin_destroy(), pthread_spin_init()

destroy or initialize a spin lock object 

Advanced Realtime


SYNOPSIS

#include <pthread.h>

int pthread_spin_destroy(pthread_spinlock_t *lock);

int pthread_spin_init(pthread_spinlock_t *lock, int pshared);


DESCRIPTION

The pthread_spin_destroy() function destroys the spin lock referenced by lock and releases any resources used by the lock.

The pthread_spin_init() function allocates the resources required to use the spin lock pointed to by the lock argument and initializes the lock to an unlocked state.

When the value of pshared is PTHREAD_PROCESS_SHARED, the spin lock can be operated upon by any thread that has access to the memory where the spin lock is allocated, even if it is allocated in memory that is shared by multiple processes.

When the value of pshared is PTHREAD_PROCESS_PRIVATE, the spin lock can only be operated upon by threads created within the same process as the thread that initialized the spin lock.

Only the object referenced by lock may be used for performing synchronization.

Referring to copies of lock in calls to the pthread_spin_destroy(), pthread_spin_lock(), pthread_spin_trylock(), and pthread_spin_unlock() functions is not recommended, while the current implementation of spin locks supports copies, there is no guarantee that future implementations will have this support.


PARAMETERS

lock 
Points to a spin lock.

pshared 

Specifies whether the spin lock can be operated upon by any thread with access to the spin lock's memory or just by threads by threads created by the initializing thread.


RETURN VALUES

On success, these functions return 0. On failure, they return one of the following error values:

EAGAIN

The system lacks the necessary resources to initialize another spin lock.

EBUSY 

An attempt to initialize or destroy a spin lock occurred while it was in use (for example, while being used in a pthread_spin_lock() call) by another thread.

EINVAL 

The value specified by lock is invalid.

ENOMEM 

Insufficient memory exists to initialize the lock.


CONFORMANCE

UNIX 03.


MULTITHREAD SAFETY LEVEL

MT-Safe.


PORTING ISSUES

None.


AVAILABILITY

PTC MKS Toolkit for Professional Developers
PTC MKS Toolkit for Professional Developers 64-Bit Edition
PTC MKS Toolkit for Enterprise Developers
PTC MKS Toolkit for Enterprise Developers 64-Bit Edition


SEE ALSO

Functions:
pthread_spin_lock(), pthread_spin_unlock()


PTC MKS Toolkit 10.4 Documentation Build 39.