1PTHREAD_SPIN_LOCK(3P)      POSIX Programmer's Manual     PTHREAD_SPIN_LOCK(3P)
2
3
4

PROLOG

6       This  manual  page is part of the POSIX Programmer's Manual.  The Linux
7       implementation of this interface may differ (consult the  corresponding
8       Linux  manual page for details of Linux behavior), or the interface may
9       not be implemented on Linux.
10
11

NAME

13       pthread_spin_lock, pthread_spin_trylock — lock a spin lock object
14

SYNOPSIS

16       #include <pthread.h>
17
18       int pthread_spin_lock(pthread_spinlock_t *lock);
19       int pthread_spin_trylock(pthread_spinlock_t *lock);
20

DESCRIPTION

22       The pthread_spin_lock() function shall lock the spin lock referenced by
23       lock.   The  calling thread shall acquire the lock if it is not held by
24       another thread. Otherwise, the thread shall spin (that  is,  shall  not
25       return from the pthread_spin_lock() call) until the lock becomes avail‐
26       able. The results are undefined if the calling thread holds the lock at
27       the  time  the  call is made. The pthread_spin_trylock() function shall
28       lock the spin lock referenced by lock if it is not held by any  thread.
29       Otherwise, the function shall fail.
30
31       The  results  are undefined if any of these functions is called with an
32       uninitialized spin lock.
33

RETURN VALUE

35       Upon successful completion, these functions shall return  zero;  other‐
36       wise, an error number shall be returned to indicate the error.
37

ERRORS

39       The pthread_spin_lock() function may fail if:
40
41       EDEADLK
42              A deadlock condition was detected.
43
44       The pthread_spin_trylock() function shall fail if:
45
46       EBUSY  A thread currently holds the lock.
47
48       These functions shall not return an error code of [EINTR].
49
50       The following sections are informative.
51

EXAMPLES

53       None.
54

APPLICATION USAGE

56       Applications  using this function may be subject to priority inversion,
57       as discussed in the Base Definitions volume  of  POSIX.1‐2008,  Section
58       3.287, Priority Inversion.
59

RATIONALE

61       If an implementation detects that the value specified by the lock argu‐
62       ment to pthread_spin_lock() or pthread_spin_trylock() does not refer to
63       an  initialized  spin  lock object, it is recommended that the function
64       should fail and report an [EINVAL] error.
65
66       If an implementation detects that the value specified by the lock argu‐
67       ment  to pthread_spin_lock() refers to a spin lock object for which the
68       calling thread already holds the lock, it is recommended that the func‐
69       tion should fail and report an [EDEADLK] error.
70

FUTURE DIRECTIONS

72       None.
73

SEE ALSO

75       pthread_spin_destroy(), pthread_spin_unlock()
76
77       The  Base  Definitions  volume of POSIX.1‐2008, Section 3.287, Priority
78       Inversion, Section 4.11, Memory Synchronization, <pthread.h>
79
81       Portions of this text are reprinted and reproduced in  electronic  form
82       from IEEE Std 1003.1, 2013 Edition, Standard for Information Technology
83       -- Portable Operating System Interface (POSIX),  The  Open  Group  Base
84       Specifications Issue 7, Copyright (C) 2013 by the Institute of Electri‐
85       cal and Electronics Engineers,  Inc  and  The  Open  Group.   (This  is
86       POSIX.1-2008  with  the  2013  Technical Corrigendum 1 applied.) In the
87       event of any discrepancy between this version and the original IEEE and
88       The  Open Group Standard, the original IEEE and The Open Group Standard
89       is the referee document. The original Standard can be  obtained  online
90       at http://www.unix.org/online.html .
91
92       Any  typographical  or  formatting  errors that appear in this page are
93       most likely to have been introduced during the conversion of the source
94       files  to  man page format. To report such errors, see https://www.ker
95       nel.org/doc/man-pages/reporting_bugs.html .
96
97
98
99IEEE/The Open Group                  2013                PTHREAD_SPIN_LOCK(3P)
Impressum