logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

sem_trywait.3p (3666B)


  1. '\" et
  2. .TH SEM_TRYWAIT "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. sem_trywait,
  12. sem_wait
  13. \(em lock a semaphore
  14. .SH SYNOPSIS
  15. .LP
  16. .nf
  17. #include <semaphore.h>
  18. .P
  19. int sem_trywait(sem_t *\fIsem\fP);
  20. int sem_wait(sem_t *\fIsem\fP);
  21. .fi
  22. .SH DESCRIPTION
  23. The
  24. \fIsem_trywait\fR()
  25. function shall lock the semaphore referenced by
  26. .IR sem
  27. only if the semaphore is currently not locked; that is, if the
  28. semaphore value is currently positive. Otherwise, it shall not lock
  29. the semaphore.
  30. .P
  31. The
  32. \fIsem_wait\fR()
  33. function shall lock the semaphore referenced by
  34. .IR sem
  35. by performing a semaphore lock operation on that semaphore. If the
  36. semaphore value is currently zero, then the calling thread shall not
  37. return from the call to
  38. \fIsem_wait\fR()
  39. until it either locks the semaphore or the call is interrupted by a
  40. signal.
  41. .P
  42. Upon successful return, the state of the semaphore shall be locked and
  43. shall remain locked until the
  44. \fIsem_post\fR()
  45. function is executed and returns successfully.
  46. .P
  47. The
  48. \fIsem_wait\fR()
  49. function is interruptible by the delivery of a signal.
  50. .SH "RETURN VALUE"
  51. The
  52. \fIsem_trywait\fR()
  53. and
  54. \fIsem_wait\fR()
  55. functions shall return zero if the calling process successfully
  56. performed the semaphore lock operation on the semaphore designated by
  57. .IR sem .
  58. If the call was unsuccessful, the state of the semaphore shall be
  59. unchanged, and the function shall return a value of \-1 and set
  60. .IR errno
  61. to indicate the error.
  62. .SH ERRORS
  63. The
  64. \fIsem_trywait\fR()
  65. function shall fail if:
  66. .TP
  67. .BR EAGAIN
  68. The semaphore was already locked, so it cannot be immediately locked by
  69. the
  70. \fIsem_trywait\fR()
  71. operation.
  72. .P
  73. The
  74. \fIsem_trywait\fR()
  75. and
  76. \fIsem_wait\fR()
  77. functions may fail if:
  78. .TP
  79. .BR EDEADLK
  80. A deadlock condition was detected.
  81. .TP
  82. .BR EINTR
  83. A signal interrupted this function.
  84. .TP
  85. .BR EINVAL
  86. The
  87. .IR sem
  88. argument does not refer to a valid semaphore.
  89. .LP
  90. .IR "The following sections are informative."
  91. .SH EXAMPLES
  92. None.
  93. .SH "APPLICATION USAGE"
  94. Applications using these functions may be subject to priority inversion,
  95. as discussed in the Base Definitions volume of POSIX.1\(hy2017,
  96. .IR "Section 3.291" ", " "Priority Inversion".
  97. .SH RATIONALE
  98. None.
  99. .SH "FUTURE DIRECTIONS"
  100. None.
  101. .SH "SEE ALSO"
  102. .IR "\fIsemctl\fR\^(\|)",
  103. .IR "\fIsemget\fR\^(\|)",
  104. .IR "\fIsemop\fR\^(\|)",
  105. .IR "\fIsem_post\fR\^(\|)",
  106. .IR "\fIsem_timedwait\fR\^(\|)"
  107. .P
  108. The Base Definitions volume of POSIX.1\(hy2017,
  109. .IR "Section 3.291" ", " "Priority Inversion",
  110. .IR "Section 4.12" ", " "Memory Synchronization",
  111. .IR "\fB<semaphore.h>\fP"
  112. .\"
  113. .SH COPYRIGHT
  114. Portions of this text are reprinted and reproduced in electronic form
  115. from IEEE Std 1003.1-2017, Standard for Information Technology
  116. -- Portable Operating System Interface (POSIX), The Open Group Base
  117. Specifications Issue 7, 2018 Edition,
  118. Copyright (C) 2018 by the Institute of
  119. Electrical and Electronics Engineers, Inc and The Open Group.
  120. In the event of any discrepancy between this version and the original IEEE and
  121. The Open Group Standard, the original IEEE and The Open Group Standard
  122. is the referee document. The original Standard can be obtained online at
  123. http://www.opengroup.org/unix/online.html .
  124. .PP
  125. Any typographical or formatting errors that appear
  126. in this page are most likely
  127. to have been introduced during the conversion of the source files to
  128. man page format. To report such errors, see
  129. https://www.kernel.org/doc/man-pages/reporting_bugs.html .