Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sem_post(3) [netbsd man page]

SEM_POST(3)						   BSD Library Functions Manual 					       SEM_POST(3)

NAME
sem_post -- increment (unlock) a semaphore LIBRARY
POSIX Real-time Library (librt, -lrt) SYNOPSIS
#include <semaphore.h> int sem_post(sem_t *sem); DESCRIPTION
The sem_post() function increments (unlocks) the semaphore pointed to by sem. If there are threads blocked on the semaphore when sem_post() is called, then the highest priority thread that has been blocked the longest on the semaphore will be allowed to return from sem_wait(). sem_post() is signal-reentrant and may be called within signal handlers. RETURN VALUES
The sem_post() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indi- cate the error. ERRORS
sem_post() will fail if: [EINVAL] sem points to an invalid semaphore. SEE ALSO
sem_trywait(3), sem_wait(3) STANDARDS
sem_post() conforms to ISO/IEC 9945-1:1996 (``POSIX.1''). BSD
January 22, 2003 BSD

Check Out this Related Man Page

SEM_POST(3)						     Linux Programmer's Manual						       SEM_POST(3)

NAME
sem_post - unlock a semaphore SYNOPSIS
#include <semaphore.h> int sem_post(sem_t *sem); Link with -lrt or -pthread. DESCRIPTION
sem_post() increments (unlocks) the semaphore pointed to by sem. If the semaphore's value consequently becomes greater than zero, then another process or thread blocked in a sem_wait(3) call will be woken up and proceed to lock the semaphore. RETURN VALUE
sem_post() returns 0 on success; on error, the value of the semaphore is left unchanged, -1 is returned, and errno is set to indicate the error. ERRORS
EINVAL sem is not a valid semaphore. EOVERFLOW The maximum allowable value for a semaphore would be exceeded. CONFORMING TO
POSIX.1-2001. NOTES
sem_post() is async-signal-safe: it may be safely called within a signal handler. EXAMPLE
See sem_wait(3). SEE ALSO
sem_getvalue(3), sem_wait(3), sem_overview(7) COLOPHON
This page is part of release 3.25 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2009-03-30 SEM_POST(3)
Man Page

3 More Discussions You Might Find Interesting

1. Programming

sem_wait, sem_post confusion?

Hi friends, I have written this small program using the concept of semaphores. I am a bit confused, hope u can help me with it. The idea is that 1. Two threads are created 2. First will be displaying 0(zero) on the screen 3. Second will be displaing 1(one) on the screen 4. This process... (2 Replies)
Discussion started by: gabam
2 Replies

2. Programming

Undefined: sem_init, sem_post, sem_wait

Hi friends, I am using semaphores in my program, but when I compile the program, it gives the following error $ gcc sem.c -o sem -lpthread Undefined first referenced symbol in file sem_init ... (1 Reply)
Discussion started by: gabam
1 Replies

3. Homework & Coursework Questions

Semaphores sem_wait sem_post problem

hallo! if there are many processes running and I initialize the semaphore like this: my_sem = sem_open(SEM_NAME, O_CREAT | O_RDWR, S_IRUSR | S_IWUSR, 10); (the last argument is 10) and then i use sem_wait(my_sem); sleep(5); sem_post; Will 10 processes be able to access the... (1 Reply)
Discussion started by: whatevernever
1 Replies