This is the mail archive of the
libc-help@sourceware.org
mailing list for the glibc project.
Re: Semaphores in libc
On Thu, Dec 31, 2009 at 11:38:12AM +0000, Paulo J. Matos wrote:
> Hi all,
>
> I am trying to find a solution for the following problem: I have a
> code region in C that should only be accessed by one process at a
> time. I have basically multiple instances of this program running but
> that bit of code, only one of the instances can be running it at that
> point.
>
> Everywhere I look I seem to find solutions for thread-based software
> etc, which is not this case.
> I thought a mutex should do it but I can't find the bit of the manual
> that actually confirms mutexes are the way to go.
POSIX semaphores is one way - if your system has linxu manpages, see
sem_overview(7). Moreover, often it is even simpler to use purely
file-based locks, it depends on what fits better the actions you
perform in the critical section.
Petr "Pasky" Baudis