ct_penalize

The ct_penalize function temporarily lowers the priority of the currently running thread.

Prototype:

void ct_penalize( unsigned penalty );

Parameters:

penalty
The requested change in priority levels.

Return Value:

None.

Discussion:

By default, a thread runs at the priority defined for it when it was created. The ct_penalize function enables a thread to lower its own priority temporarily by a specified number of priority levels. If the specified change is excessive, ct_penalize() applies the lowest possible priority.

For example, after a time-consuming I/O operation, a thread may lower its own priority in order to give other threads a chance to catch up.

The lowered priority is effective only for the next invocation of the thread. After that, the thread returns to its normal priority level, unless it calls ct_penalize() again.

There is no corresponding function whereby a thread may raise its priority. The use of priority levels by the scheduler is discussed in detail elsewhere.

If the thread returns without emptying its message queue, the call to ct_penalize() will be ignored. The scheduler will enqueue the thread for execution at the highest priority.

Restrictions:

The ct_penalize function may be called only from a thread or user exit, i.e. when the scheduler is running.
Home