02-10-2010
Hello Snowbarr,
Well, it's a tradition in POSIX threads to avoid semaphores whenever possible ... Corona688 idea to use condition variables (with a broadcast) is a good, see man pthread_cond_broadcast() and pthread_cond_wait() among others,
Another possibility, that may even better fit, could be using a barrier: see man pthread_barrier_init() and pthread_barrier_wait().
HTH,
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 FREEBSD
pthread_barrier_wait
PTHREAD_BARRIER(3) BSD Library Functions Manual PTHREAD_BARRIER(3)
NAME
pthread_barrier_destroy, pthread_barrier_init, pthread_barrier_wait -- destroy, initialize or wait on a barrier object
LIBRARY
POSIX Threads Library (libpthread, -lpthread)
SYNOPSIS
#include <pthread.h>
int
pthread_barrier_destroy(pthread_barrier_t *barrier);
int
pthread_barrier_init(pthread_barrier_t *barrier, const pthread_barrierattr_t *attr, unsigned count);
int
pthread_barrier_wait(pthread_barrier_t *barrier);
DESCRIPTION
The pthread_barrier_init() function will initialize barrier with attributes specified in attr, or if it is NULL, with default attributes.
The number of threads that must call pthread_barrier_wait() before any of the waiting threads can be released is specified by count. The
pthread_barrier_destroy() function will destroy barrier and release any resources that may have been allocated on its behalf.
The pthread_barrier_wait() function will synchronize calling threads at barrier. The threads will be blocked from making further progress
until a sufficient number of threads calls this function. The number of threads that must call it before any of them will be released is
determined by the count argument to pthread_barrier_init(). Once the threads have been released the barrier will be reset.
IMPLEMENTATION NOTES
In both N:M Threading Library (libkse, -lkse) and 1:1 Threading Library (libthr, -lthr) the PTHREAD_BARRIER_SERIAL_THREAD return value will
always be returned by the last thread to reach the barrier.
RETURN VALUES
If successful, both pthread_barrier_destroy() and pthread_barrier_init() will return zero. Otherwise, an error number will be returned to
indicate the error. If the call to pthread_barrier_wait() is successful, all but one of the threads will return zero. That one thread will
return PTHREAD_BARRIER_SERIAL_THREAD. Otherwise, an error number will be returned to indicate the error.
None of these functions will return EINTR.
ERRORS
The pthread_barrier_destroy() function will fail if:
[EBUSY] An attempt was made to destroy barrier while it was in use.
The pthread_barrier_destroy() and pthread_barrier_wait() functions may fail if:
[EINVAL] The value specified by barrier is invalid.
The pthread_barrier_init() function will fail if:
[EAGAIN] The system lacks resources, other than memory, to initialize barrier.
[EINVAL] The count argument is less than 1.
[ENOMEM] Insufficient memory to initialize barrier.
SEE ALSO
pthread_barrierattr(3)
HISTORY
The pthread_barrier_destroy(), pthread_barrier_init() and pthread_barrier_wait() functions first appeared in N:M Threading Library (libkse,
-lkse) in FreeBSD 5.2, and in 1:1 Threading Library (libthr, -lthr) in FreeBSD 5.3.
BSD
February 19, 2004 BSD