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

NAME

12       pthread_spin_lock, pthread_spin_trylock — lock a spin lock object
13

SYNOPSIS

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

DESCRIPTION

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

RETURN VALUE

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

ERRORS

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

EXAMPLES

52       None.
53

APPLICATION USAGE

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

RATIONALE

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

FUTURE DIRECTIONS

71       None.
72

SEE ALSO

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