Standards / Extensions | C or C++ | Dependencies |
---|---|---|
POSIX.4a |
both | POSIX(ON) |
#define _OPEN_THREADS
#include <pthread.h>
int pthread_cond_signal(pthread_cond_t *cond);
#define _UNIX03_THREADS
#include <pthread.h>
int pthread_cond_signal(pthread_cond_t *cond);
Unblock at least one thread that is blocked on the specified condition variable, cond. If more than one thread is blocked, the order in which the threads are unblocked is unspecified.
pthread_cond_signal() will have no effect if there are no threads currently blocked on cond.
If successful, pthread_cond_signal() returns 0.
Special behavior for Single UNIX Specification, Version 3: If unsuccessful, pthread_cond_signal() returns an error number to indicate the error.
⁄* CELEBP20 *⁄
#define _OPEN_THREADS
#include <pthread.h>
#include <stdio.h>
main() {
pthread_cond_t cond;
if (pthread_cond_init(&cond, NULL) != 0) {
perror("pthread_cond_init() error");
exit(1);
}
if (pthread_cond_signal(&cond) != 0) {
perror("pthread_cond_broadcast() error");
exit(2);
}
if (pthread_cond_destroy(&cond) != 0) {
perror("pthread_cond_destroy() error");
exit(3);
}
}