Multithreaded Programming Guide

Exit Print View

Updated: July 2014
 
 

Unlocking a Spin Lock

Use the pthread_spin_unlock(3C) function to release a locked spin lock.

pthread_spin_unlock() Syntax

int  pthread_spin_unlock(pthread_spinlock_t *lock);
#include <pthread.h>

pthread_spinlock_t lock;
int ret;

ret = pthread_spin_unlock(&lock); /* spinlock is unlocked */

pthread_spin_unlock() Return Values

Upon successful completion, the pthread_spin_unlock() function returns 0. Otherwise, one of the following error codes is returned.

EPERM

Description: The calling thread does not hold the lock.

EINVAL

Description: The value specified by lock does not refer to an initialized spin lock object.