Sponsored Content
Top Forums Programming Question (pthread): How to Signal all threads w/o "broadcast"? Post 302519048 by Loic Domaigne on Tuesday 3rd of May 2011 12:09:04 AM
Old 05-03-2011
You can either:
- wake all the threads waiting on the condvar with pthread_cond_broadcast,
- or wake one of the thread waiting on the condvar with pthread_cond_signal (which one is left to the libpthread/OS).

What are you trying to achieve exactly?

Cheers, Loïc
 

8 More Discussions You Might Find Interesting

1. Linux

Strange error "host: isc_taskmgr_create: no available threads"

Dear Srs, I'm getting this error on a Linux box, running Apache 2.0.52: "host: isc_taskmgr_create: no available threads" Making some search for those strings in Google, didn't tell me anything about this.. appears to be related to SELinux, but it's disabled in the box. Any idea about... (0 Replies)
Discussion started by: Santi
0 Replies

2. UNIX and Linux Applications

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or question of my own) is: Oracle tns listener, "CT_LISTENER", and the enterprise manager (EM) of the instance, which is uniq instance and called... (0 Replies)
Discussion started by: talipk
0 Replies

3. UNIX for Advanced & Expert Users

A question/problem about oracle "tns listener" and "enterprise manager"

hi, I have a problem about the Oracle related components. I'm not able to find any answer yet, and waiting for your responses... Here is the configuration of my system: * an IBM P550 machine, * an AIX 5.3 running on it and * an oracle database, already installed on it. The problem (or... (1 Reply)
Discussion started by: talipk
1 Replies

4. Solaris

Solaris 10 install issue - "Caught Signal 11"

Rebuilding a server (T2000) from a flash archive I created on another server. Using a Solaris 10/08 DVD to boot from the was going to point it tot he flash archive and pull it over NFS. I've done this many times with success until now. It initially boots off the DVD, you input the... (5 Replies)
Discussion started by: Probos
5 Replies

5. Shell Programming and Scripting

awk command to replace ";" with "|" and ""|" at diferent places in line of file

Hi, I have line in input file as below: 3G_CENTRAL;INDONESIA_(M)_TELKOMSEL;SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL My expected output for line in the file must be : "1-Radon1-cMOC_deg"|"LDIndex"|"3G_CENTRAL|INDONESIA_(M)_TELKOMSEL"|LAST|"SPECIAL_WORLD_GRP_7_FA_2_TELKOMSEL" Can someone... (7 Replies)
Discussion started by: shis100
7 Replies

6. Solaris

Trap signal on Window Manager "X" button clicked?

Well, my first post... thanks in advance! Can applications be notified of the X Window close (with "X" button) so the signal handler can run a cleanup process method? About the app: built with GNU C/C++ on Solaris 10, with WxWidgets. It is launched by a shell script as a background task. The... (2 Replies)
Discussion started by: HandsOGold
2 Replies

7. Solaris

Solaris 10 "Exiting (caught signal 11)"

I get an error after the initializing screen. I am using a DVD/ROM to boot up the installation on a Dell Inspiron 1520. Segmentation fault - core dumped. I have tried to restart multiple times. Please help (1 Reply)
Discussion started by: Jimasaurus
1 Replies

8. Shell Programming and Scripting

Bash script - Print an ascii file using specific font "Latin Modern Mono 12" "regular" "9"

Hello. System : opensuse leap 42.3 I have a bash script that build a text file. I would like the last command doing : print_cmd -o page-left=43 -o page-right=22 -o page-top=28 -o page-bottom=43 -o font=LatinModernMono12:regular:9 some_file.txt where : print_cmd ::= some printing... (1 Reply)
Discussion started by: jcdole
1 Replies
PTHREAD_COND(3) 					   BSD Library Functions Manual 					   PTHREAD_COND(3)

NAME
pthread_cond -- condition variable interface LIBRARY
POSIX Threads Library (libpthread, -lpthread) SYNOPSIS
#include <pthread.h> int pthread_cond_init(pthread_cond_t * restrict cond, const pthread_condattr_t * restrict attr); int pthread_cond_destroy(pthread_cond_t *cond); int pthread_cond_broadcast(pthread_cond_t *cond); int pthread_cond_signal(pthread_cond_t *cond); int pthread_cond_wait(pthread_cond_t * restrict cond, pthread_mutex_t * restrict mutex); int pthread_cond_timedwait(pthread_cond_t * restrict cond, pthread_mutex_t * restrict mutex, const struct timespec * restrict abstime); pthread_cond_t cond = PTHREAD_COND_INITIALIZER; DESCRIPTION
Condition variables are intended to be used to communicate changes in the state of data shared between threads. Condition variables are always associated with a mutex to provide synchronized access to the shared data. A single predicate should always be associated with a con- dition variable. The predicate should identify a state of the shared data that must be true before the thread proceeds. The pthread_cond_init() function creates a new condition variable, with attributes specified with attr. If attr is NULL the default attributes are used. The pthread_cond_destroy() function frees the resources allocated by the condition variable cond. The macro PTHREAD_COND_INITIALIZER can be used to initialize a condition variable when it can be statically allocated and the default attributes are appropriate. The effect is similar to calling pthread_cond_init() with attr specified as NULL, except that no error checking is done. The difference between pthread_cond_broadcast() and pthread_cond_signal() is that the former unblocks all threads waiting for the condition variable, whereas the latter blocks only one waiting thread. If no threads are waiting on cond, neither function has any effect. If more than one thread is blocked on a condition variable, the used scheduling policy determines the order in which threads are unblocked. The same mutex used for waiting must be held while calling either function. Although neither function strictly enforces this requirement, undefined behavior may follow if the mutex is not held. The pthread_cond_wait() function atomically blocks the current thread waiting on the condition variable specified by cond, and unlocks the mutex specified by mutex. The pthread_cond_timedwait() function behaves similarly, but unblocks also if the system time reaches the time specified in abstime, represented as struct timespec (see timespec(3)). With both functions the waiting thread unblocks after another thread calls pthread_cond_signal() or pthread_cond_broadcast() with the same condition variable and by holding the same mutex that was associated with cond by either one of the blocking functions. The current thread holds the lock on mutex upon return from either function. Note that a call to pthread_cond_wait() or pthread_cond_timedwait() may wake up spontaneously, without a call to pthread_cond_signal() or pthread_cond_broadcast(). The caller should prepare for this by invoking either function within a predicate loop that tests whether the thread should proceed. As noted, when calling either function that waits on a condition variable, a temporary binding is established between the condition variable cond and the mutex mutex. During this time, the effect of an attempt by any thread to wait on that condition variable using a different mutex is undefined. The same mutex must be held while broadcasting or signaling on cond. Additionally, the same mutex must be used for con- current calls to pthread_cond_wait() and pthread_cond_timedwait(). Only when a condition variable is known to be quiescent may an applica- tion change the mutex associated with it. In this implementation, none of the functions enforce this requirement, but if the mutex is not held or independent mutexes are used the resulting behaviour is undefined. RETURN VALUES
If successful, all functions return zero. Otherwise, an error number will be returned to indicate the error. ERRORS
The pthread_cond_init() function may fail if: [EINVAL] The value specified by attr is invalid. The pthread_cond_destroy() function may fail if: [EBUSY] The variable cond is locked by another thread. [EINVAL] The value specified by cond is invalid. Both pthread_cond_broadcast() and pthread_cond_signal() may fail if: [EINVAL] The value specified by cond is invalid. Both pthread_cond_wait() and pthread_cond_timedwait() may fail if: [EINVAL] The value specified by cond or the value specified by mutex is invalid. [EPERM] The value specified by mutex was not locked in the condition wait. The pthread_cond_timedwait() function may additionally fail if: [ETIMEDOUT] The system time has reached or exceeded the time specified in abstime. SEE ALSO
pthread(3), pthread_barrier(3), pthread_condattr(3), pthread_mutex(3), pthread_rwlock(3), pthread_spin(3) STANDARDS
These functions conform to IEEE Std 1003.1-2001 (``POSIX.1''). BSD
July 8, 2010 BSD
All times are GMT -4. The time now is 12:54 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy