HP OpenVMS Systems Documentation |
Guide to the POSIX Threads Library
sched_get_priority_min
Returns the minimum priority for the specified scheduling policy. Syntaxsched_get_priority_min(C Binding #include <sched.h>
int
Arguments
DescriptionThis routine returns the minimum priority for the scheduling policy specified in the policy argument. The argument value must be one of the scheduling policies ( SCHED_FIFO , SCHED_RR , or SCHED_OTHER ), as defined in the sched.h header file.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
sched_yield
Yields execution to another thread. Syntaxsched_yield( );C Binding #include <sched.h> #include <unistd.h>
int
ArgumentsNone DescriptionIn conformance with the IEEE POSIX.1-1996 standard, the sched_yield() function causes the calling thread to yield execution to another thread. It is useful when a thread running under the SCHED_FIFO scheduling policy must allow another thread at the same priority to run. The thread that is interrupted by sched_yield() goes to the end of the queue for its priority.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Associated Routinespthread_attr_setschedparam() sigwait
Suspends a calling thread until a signal arrives. Syntaxsigwait(C Binding #include <signal.h>
int
Arguments
DescriptionThis routine blocks the calling thread until at least one of the signals in the set argument is in the caller's set of pending signals. When this happens, one of those signals is automatically selected and removed from the set of pending signals. The signal number identifying that signal is then returned.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:
Part 3
Part 3 provides detailed descriptions of the Compaq proprietary
thread-independent services (or tis) interface
routines.
|
Never use tis_cond_wait() in a nonthreaded environment. It cannot wait, as there would be no thread able to awaken the waiter. The tis "stub" will abort your program. |
When threads are present, the guidelines for using pthread routines apply to using the corresponding tis routines.
Wakes all threads that are waiting on a condition variable.
tis_cond_broadcast(C Binding #include <tis.h>
cond );
Argument Data Type Access cond opaque pthread_cond_t modify
int
tis_cond_broadcast (
pthread_cond_t *cond);
cond
Address of the condition variable (passed by reference) on which to broadcast.
When threads are not present, this routine has no effect.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:When threads are present, this routine unblocks all threads waiting on the specified condition variable cond.
For further information about actions when threads are present, refer to the pthread_cond_broadcast() description.
Return | Description |
---|---|
0 | Successful completion. |
[EINVAL] | The value specified by cond is not a valid condition variable. |
tis_cond_destroy()
tis_cond_init()
tis_cond_signal()
tis_cond_wait()
Destroys the specified condition variable.
tis_cond_destroy(C Binding #include <tis.h>
cond );
Argument Data Type Access cond opaque pthread_cond_t write
int
tis_cond_destroy (
pthread_cond_t *cond);
cond
Address of the condition variable (passed by reference) to be destroyed.
This routine destroys the condition variable specified by cond. After this routine is called, the Threads Library may reclaim internal storage used by the condition variable object. Call this routine when a condition variable will no longer be referenced.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:The results of this routine are unpredictable if the condition variable specified in cond does not exist or is not initialized.
For more information about actions when threads are present, refer to the pthread_cond_destroy() description.
Return | Description |
---|---|
0 | Successful completion. |
[EBUSY] |
The object being referenced by
cond is being referenced by another thread that is currently
executing a
tis_cond_wait() on the condition variable specified in cond. (This error can only occur when threads are present.) |
[EINVAL] | The value specified by cond is not a valid condition variable. |
tis_cond_broadcast()
tis_cond_init()
tis_cond_signal()
tis_cond_wait()
Initializes a condition variable.
tis_cond_init(C Binding #include <tis.h>
cond );
Argument Data Type Access cond opaque pthread_cond_t write
int
tis_cond_init (
pthread_cond_t *cond);
cond
Address of the condition variable (passed by reference) to be initialized.
This routine initializes a condition variable (cond) with the Threads Library default condition variable attributes.Return Values If there is an error condition, the following occurs:A condition variable is a synchronization object used with a mutex. A mutex controls access to shared data. When threads are present, a condition variable allows threads to wait for data to enter a defined state.
For more information about actions taken when threads are present, refer to the pthread_cond_init() description.
Your program can use the macro PTHREAD_COND_INITIALIZER to initialize statically allocated condition variables to the default condition variable attributes. Static initialization can be used only for a condition variable with storage class "extern" or "static" --- "automatic" (stack local) objects must be initialized by calling tis_cond_init() . Use this macro as follows:
pthread_cond_t condition = PTHREAD_COND_INITIALIZER ;When statically initialized, a condition variable should not also be initialized using tis_cond_init() .
The possible return values are as follows:
Return | Description |
---|---|
0 | Successful completion. |
[EAGAIN] |
The system lacks the necessary resources to initialize another
condition variable, or
The system-imposed limit on the total number of condition variables under execution by a single user is exceeded. |
[EBUSY] | The implementation has detected an attempt to reinitialize the object referenced by cond, a previously initialized, but not yet destroyed condition variable. |
[EINVAL] | The value specified by cond is not a valid condition variable. |
[ENOMEM] | Insufficient memory to initialize the condition variable. |
tis_cond_broadcast()
tis_cond_destroy()
tis_cond_signal()
tis_cond_wait()
Wakes at least one thread that is waiting on the specified condition variable.
tis_cond_signal(C Binding #include <tis.h>
cond );
Argument Data Type Access cond opaque pthread_cond_t modify
int
tis_cond_signal (
pthread_cond_t *cond);
cond
Address of the condition variable (passed by reference) on which to signal.
When threads are present, this routine unblocks at least one thread that is waiting on the specified condition variable cond. When threads are not present, this routine has no effect.Return Values If an error condition occurs, this routine returns an integer value indicating the type of error. Possible return values are as follows:For more information about actions taken when threads are present, refer to the pthread_cond_signal() description.
Return | Description |
---|---|
0 | Successful completion. |
[EINVAL] | The value specified by cond is not a valid condition variable. |
tis_cond_broadcast()
tis_cond_destroy()
tis_cond_init()
tis_cond_wait()
Causes a thread to wait for the specified condition variable to be signaled or broadcast, such that it will awake after a specified period of time.
tis_cond_timedwait(C Binding #include <tis.h>
cond ,
mutex ,
abstime );
Argument Data Type Access cond opaque pthread_cond_t modify mutex opaque pthread_mutex_t modify abstime structure timespec read
int
tis_cond_timedwait (
pthread_cond_t *cond,
pthread_mutex_t *mutex,
const struct timespec *abstime);
cond
Condition variable that the calling thread waits on.mutex
Mutex associated with the condition variable specified in cond.abstime
Absolute time at which the wait expires, if the condition has not been signaled or broadcast. See the tis_get_expiration() routine, which is used to obtain a value for this argument.The abstime argument is specified in Universal Coordinated Time (UTC). In the UTC-based model, time is represented as seconds since the Epoch. The Epoch is defined as the time 0 hours, 0 minutes, 0 seconds, January 1st, 1970 UTC.
If threads are not present, this function is equivalent to sleep() .Return Values If an error condition occurs, this routine returns an integer indicating the type of error. Possible return values are as follows:This routine causes a thread to wait until one of the following occurs:
- The specified condition variable is signaled or broadcast.
- The current system clock time is greater than or equal to the time specified by the abstime argument.
This routine is identical to tis_cond_wait() , except that this routine can return before a condition variable is signaled or broadcast, specifically, when the specified time expires. For more information, see the tis_cond_wait() description.
This routine atomically releases the mutex and causes the calling thread to wait on the condition. When the thread regains control after calling tis_cond_timedwait() , the mutex is locked and the thread is the owner. This is true regardless of why the wait ended. If general cancelability is enabled, the thread reacquires the mutex (blocking for it if necessary) before the cleanup handlers are run (or before the exception is raised).
If the current time equals or exceeds the expiration time, this routine returns immediately, releasing and reacquiring the mutex. It might cause the calling thread to yield (see the sched_yield() description). Your code should check the return status whenever this routine returns and take the appropriate action. Otherwise, waiting on the condition variable can become a nonblocking loop.
Call this routine after you have locked the mutex specified in mutex. The results of this routine are unpredictable if this routine is called without first locking the mutex. The only routines that are supported for use with asynchronous cancelability enabled are those that disable asynchronous cancelability.
Return | Description |
---|---|
0 | Successful completion. |
[EINVAL] |
The value specified by
cond,
mutex, or
abstime is invalid, or
Different mutexes are supplied for concurrent
The mutex was not owned by the calling thread at the time of the call. |
[ETIMEDOUT] | The time specified by abstime expired. |
[ENOMEM] | The Threads Library cannot acquire memory needed to block using a statically initialized condition variable. |
tis_cond_broadcast()
tis_cond_destroy()
tis_cond_init()
tis_cond_signal()
tis_cond_wait()
tis_get_expiration()
Previous | Next | Contents | Index |