[Prev] [Contents] [Next]
Thread Priority and Scheduling:
The default thread creation attributes of the AS400 implementation of pthreads uses an explicitly specified priority of DEFAULT_PRIO_NP. Some implementations by default, inherit the scheduling priority and policy of the creating thread. For performance reasons, the AS/400 implementation chooses to start each thread with an explicitly priority so that during thread creation, the run-time need not retrieve the priority of the creating thread.
An AS/400 thread competes for scheduling resources against other threads in the system, not solely against other threads in the process. The scheduler is a delay cost scheduler based on several delay cost curves (priority ranges). The Posix standard and the Single Unix Specification refers to this as scheduling scope and scheduling policy, which on this implementation cannot be changed from the default of SCHED_OTHER.
These Pthread APIs support only a scheduling policy of SCHED_OTHER.
- pthread_setschedparam (SCHED_OTHER only supported)
- pthread_getschedparam
- pthread_attr_setschedparam
- pthread_attr_getschedparam
The priority of a thread is specified as a delta which is added to the priority of the process. Changing the priority of the process, effects the priority of all of the threads within that process. The default priority for a thread is DEFAULT_PRIO_NP, which is no change from the process priority.
On the AS/400, numerically lower priority values indicate higher priority with regard to scheduling. The pthread.h and sched.h header files define the priority constants in a way that is consistent with the threads standard, but opposite of priority specifications on the AS/400. When you use specify a priority of -99 in a call to pthread_setschedparam(), the priority of the target thread is lowered to the lowest possible value.
- For example: Process P1 is at AS/400 priority 20 and contains a thread T1 that specifies a Pthread priority adjustment of -18. Process P2 is at AS/400 priority 25 and contains thread T2 that specifies a priority of -5. The result is that the system schedules the threads using the AS/400 priority for T1 as 38, and for T2 as 30. The thread scheduling is specified at a system level, and although process P2 runs at a lower priority ranking than process P1, thread T2 within process P2 runs at a higher priority ranking than thread T1 in process P1, and thus gets more processing resources.
[Prev] [Contents] [Next]
Copyright © 1998, IBM Corporation. All rights
reserved.
Comments? Contact rchthrds@us.ibm.com