![]() |
|
||||
POSIX 1.b Migration Guide |
Scheduling
Scheduler Priority
The main difference in scheduling functionality is the way scheduling priorities are handled. In Draft 9, scheduling priorities are defined as type int. However, POSIX.1b defines a new structure, sched_param, which encloses the priority field as type sched_priority. A pointer to the structure sched_param must be passed to all scheduling functions. An example of these changes is shown below.
Draft 9 code
Equivalent POSIX.1b code
Changes to Macros
Another minor change is that a number of Draft 9 macros are replaced by functions in POSIX.1b as explained in the table below.
Scheduling Interface Changes Draft 9 POSIX.1b No EquivalentThe following examples illustrates these changes:
Draft 9 code
Equivalent POSIX.1b code
Macros vs. Functions
Draft 9 defines a number of macros for certain scheduler parameters. Six of these macros defined the minimum and maximum scheduler priorities for the three scheduling policies:
These were replaced by two functions in POSIX.1b. The function sched_get_priority_min() takes a scheduling policy as input and returns the minimum priority for it. The function sched_get_priority_max() takes a scheduling policy as input and returns the maximum priority for it.
Draft 9 defines the macro RR_INTERVAL for the interval for the SCHED_RR policy. This is replaced by a new function sched_rr_get_interval() in POSIX.1b.
yield ()
The Draft 9 yield() function does not return anything, and sets no error numbers. The equivalent sched_yield() function in POSIX.1b returns an int and sets an error number on failure.
SCHED_OTHER
The behavior for the SCHED_OTHER scheduling policy has not changed. This is the same as SCHED_DEFAULT, which is the LynxOS proprietary scheduling policy.
Non-Preemptible Scheduling Policy
LynxOS implements a non-preemptible scheduling policy called SCHED_NONPREEMPT. A process running under this policy cannot be preempted by any other process until it voluntarily sleeps or blocks waiting for a semaphore or mutex object. An example of this policy is a garbage collector running with low priority and performing critical work so that it must not be interrupted. The sample code of the application is as follows:
LynxOS also defines 2 constants for the SCHED_NONPREEMPT policy designating the maximum and minimum priorities for this policy. These constants are:
These priorities can also be obtained using the sched_get_priority_max() and sched_get_priority_min() functions.
Interoperability
There have been no changes in the standard scheduling facilities, and, therefore, interoperability is preserved. Two processes, one using Draft 9 scheduling and another using POSIX.1b scheduling would get the CPU slices as if they used the same version of scheduling.
![]() LynuxWorks, Inc. 855 Branham Lane East San Jose, CA 95138 http://www.lynuxworks.com 1.800.255.5969 |
![]() |
![]() |
![]() |
![]() |