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

NAME

6       pthread_spin_lock,  pthread_spin_trylock  -  lock  a  spin  lock object
7       (ADVANCED REALTIME THREADS)
8

SYNOPSIS

10       #include <pthread.h>
11
12       int pthread_spin_lock(pthread_spinlock_t *lock);
13       int pthread_spin_trylock(pthread_spinlock_t *lock);
14
15

DESCRIPTION

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

RETURN VALUE

30       Upon successful completion, these functions shall return  zero;  other‐
31       wise, an error number shall be returned to indicate the error.
32

ERRORS

34       These functions may fail if:
35
36       EINVAL The  value  specified  by  lock does not refer to an initialized
37              spin lock object.
38
39
40       The pthread_spin_lock() function may fail if:
41
42       EDEADLK
43              The calling thread already holds the lock.
44
45
46       The pthread_spin_trylock() function shall fail if:
47
48       EBUSY  A thread currently holds the lock.
49
50
51       These functions shall not return an error code of [EINTR].
52
53       The following sections are informative.
54

EXAMPLES

56       None.
57

APPLICATION USAGE

59       Applications using this function may be subject to priority  inversion,
60       as  discussed  in  the Base Definitions volume of IEEE Std 1003.1-2001,
61       Section 3.285, Priority Inversion.
62
63       The pthread_spin_lock() and pthread_spin_trylock() functions  are  part
64       of  the  Spin  Locks option and need not be provided on all implementa‐
65       tions.
66

RATIONALE

68       None.
69

FUTURE DIRECTIONS

71       None.
72

SEE ALSO

74       pthread_spin_destroy() , pthread_spin_unlock() , the  Base  Definitions
75       volume of IEEE Std 1003.1-2001, <pthread.h>
76
78       Portions  of  this text are reprinted and reproduced in electronic form
79       from IEEE Std 1003.1, 2003 Edition, Standard for Information Technology
80       --  Portable  Operating  System  Interface (POSIX), The Open Group Base
81       Specifications Issue 6, Copyright (C) 2001-2003  by  the  Institute  of
82       Electrical  and  Electronics  Engineers, Inc and The Open Group. In the
83       event of any discrepancy between this version and the original IEEE and
84       The  Open Group Standard, the original IEEE and The Open Group Standard
85       is the referee document. The original Standard can be  obtained  online
86       at http://www.opengroup.org/unix/online.html .
87
88
89
90IEEE/The Open Group                  2003                 PTHREAD_SPIN_LOCK(P)
Impressum