[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]

General Programming Concepts: Writing and Debugging Programs


Scheduling

In previous versions of AIX, up to AIX 3.2, the process was the schedulable entity. Several commands and subroutines influenced on-process scheduling. The introduction of threads changed the semantics of these commands and subroutines.

Read the following to learn more about changes in process scheduling:

Process-Level Scheduling

In AIX Version 4, the scheduler allocates processor time to threads based on each thread's priority and scheduling policy. Previously, AIX scheduled processes and did not support threads: process priority depended on nice values, which were managed with the nice and renice commands and the getpriority, setpriority, and nice subroutines. While these interfaces still exist, process nice values are only used in the default scheduling policy, denoted SCHED_OTHER, which uses the nice value and recent CPU usage to calculate priority. The other scheduling policies are fixed priority. The getpri and setpri subroutines previously managed process priority. They now manage thread priority and respectively return the priority of a thread in the process, or set the priority of all threads in a process.

The yield subroutine previously caused a process to relinquish the processor, allowing a higher priority process to be scheduled immediately, before the end of its time slice. In a multi-threaded process, only the calling thread gives up its time slice. Threads can use the pthread_yield service to yield the processor. If the contention scope is global, the behavior is as with yield, and any thread can be scheduled; if the scope is local, another local thread will be scheduled.

Timer and Sleep Subroutines

Timer routines now execute in the context of the calling thread, instead of the calling process. Thus, if a timer expires, the watchdog timer function is called in the thread's context. When a process or thread goes to sleep, it relinquishes the processor. In a multi-threaded process, only the calling thread is put to sleep.

Related Information

Understanding Threads.

Threads-Processes Interactions Overview.

Signal Management.

Process Duplication and Termination.

List of Threads-Processes Interactions Subroutines.


[ Previous | Next | Table of Contents | Index | Library Home | Legal | Search ]