02-19-2010
Quote:
Originally Posted by Corona688
Quote:
Originally Posted by Loic Domaigne
Well, it's a tradition in POSIX threads to avoid semaphores whenever possible
How come?
Well, this is a joke coming from the comp.programming.threads NG.
The reason behind this joke is: in most of the cases, POSIX threads offers synchronization mechanisms that surpass what semaphores can offer. For instance, a mutex could be seen as a binary semaphore. But mutex is more efficient in the uncontended case (indeed, there is no kernel involvement. This is not the case for semaphore). Beside that, mutex can offer priority inheritance, something impossible with semaphore.
From my own experience, most of the time where semaphores are used in Pthreads program often results from a lack of Pthreads understanding. There are only very few specific cases where semaphores make more sense.
Cheers,
Loïc.
10 More Discussions You Might Find Interesting
1. Programming
Hi,
I am trying to write stuff to a shared memory using a writer, and reading the corresponding stuff using a reader. I am facing problems while releasing the lock, as a result of which I am having segmentation faults. The code is as follows...
/********** writer.c ***********/
... (1 Reply)
Discussion started by: jacques83
1 Replies
2. Programming
Hi,
does anybody know, if it is possible to replace mutex with POSIX semaphore?
I'm gonna to rewrite old thread's program with processes and I don't want rewrite most of the code...So if I replace the threads with processes and mutexes with semaphores WILL IT WORK?
Before, the critical... (1 Reply)
Discussion started by: michael26100
1 Replies
3. Solaris
Hi,
One of my prod jobs using Ab Initio (which is Solaris Based) returned this error:
========= Error from Reformat_3.000 on f7j21-01.xxxx3.com ========= Failed opening file for flow: Resource temporarily unavailable
Flow = "Flow_11.000" connected to output port "out0" of "Reformat_3.000"... (0 Replies)
Discussion started by: teenu18
0 Replies
4. Linux
Hi all
i am facing a problem with ext3 file system
df -h is showing 19gb is used even if there is not a single file on the mount point
/dev/mapper/vg01-archive
55G 19G 33G 36% /archive_log
OS == Linux cdrsvr 2.6.9-55.ELsmp #1 SMP Fri Apr 20 17:03:35 EDT 2007... (1 Reply)
Discussion started by: ajays
1 Replies
5. Filesystems, Disks and Memory
I have a volume managed by Veritas Storage Migrator 6.0 running on Solaris 10. It has one managed volume and one tape robot it shares with netpackup (separate volume pools). When I check the process tree I am not seeing any migration processes running, but when I check the panel on the tape robot... (0 Replies)
Discussion started by: ilikecows
0 Replies
6. Solaris
Hi Guys !
I have found this problem many times that the swap space (/tmp space more precisely )of my Server becomes full specially when i run a complete back up of the server .
once the /tmp space is full I am not able to run simple commands as i get error like :
fork no space
on... (6 Replies)
Discussion started by: Paarth
6 Replies
7. Solaris
Hi Guys !
I have found this problem many times that the swap space (/tmp space more precisely )of my Server becomes full specially when i run a complete back up of the server .
once the /tmp space is full I am not able to run simple commands as i get error like :
fork no space
on... (4 Replies)
Discussion started by: Paarth
4 Replies
8. AIX
Hey Guys,
I need a help,
After I upgraded my server to AIX 6.1.4 the port 80 is occupied by a Java process
bash-3.00# netstat -Aan | grep "*.80"
f1000700007d7bb0 tcp 0 0 *.80 *.* LISTEN
bash-3.00# rmsock f1000700007d7bb0 tcp
usage: rmsock Addr... (2 Replies)
Discussion started by: kkeng808
2 Replies
9. AIX
Hi everyone,
i have a question about the Memory Management in AIX 6.1.
I have
- 128 GB RAM and
- 70 GB Page Space.
The application i am running on this machine is doing some operations in perl. These are done only once a day and uses both memory and paging space. My problem... (1 Reply)
Discussion started by: Haichao
1 Replies
10. UNIX for Beginners Questions & Answers
Hi all,
I would greatly appreciate some help with this. I may not even be on the right path but I think I am close.
I have a Synology NAS that I am running rsync jobs on to offload to USB3. These work fine.
I have backup software on our Windows Server 2008R2 that I have now realized can... (2 Replies)
Discussion started by: stefshuuj
2 Replies
LEARN ABOUT NETBSD
sem_getvalue
SEM_GETVALUE(3) BSD Library Functions Manual SEM_GETVALUE(3)
NAME
sem_getvalue -- get the value of a semaphore
LIBRARY
POSIX Real-time Library (librt, -lrt)
SYNOPSIS
#include <semaphore.h>
int
sem_getvalue(sem_t * restrict sem, int * restrict sval);
DESCRIPTION
The sem_getvalue() function sets the variable pointed to by sval to the current value of the semaphore pointed to by sem, as of the time that
the call to sem_getvalue() is actually run.
RETURN VALUES
The sem_getvalue() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to
indicate the error.
ERRORS
sem_getvalue() will fail if:
[EINVAL] sem points to an invalid semaphore.
SEE ALSO
sem_post(3), sem_trywait(3), sem_wait(3)
STANDARDS
sem_getvalue() conforms to ISO/IEC 9945-1:1996 (``POSIX.1'').
The value of the semaphore is never negative, even if there are threads blocked on the semaphore. POSIX is somewhat ambiguous in its wording
with regard to what the value of the semaphore should be if there are blocked waiting threads, but this behavior is conformant, given the
wording of the specification.
BSD
January 22, 2003 BSD