Первоначально опубликовано Draggan
А как с этим обстоит в OS/2? Я как-то не помню, да глянуть негде, а Вы вроде должны знать. Напишите, любопытно.
|
===========================
OS/2 performs prioritized, preemptive, multitasking. Prioritized means that OS/2 does not divide CPU time equally among all threads. All programs do not get equal access to the CPU. A prioritizing, time-slicing strategy is used to allocate access to the CPU among competing threads. Each thread has a priority and OS/2 runs the highest priority thread that is ready to run. Programs with higher priorities (a real-time robotic application, for example), are given access to the CPU before programs with lower priorities. If a thread with a higher priority than the currently running thread becomes ready to run, the current thread is stopped immediately, or preempted, and the higher priority thread is given the CPU. The lower priority thread does not get to complete its time slice. Threads of equal priority are given CPU time in a round-robin manner.
Preemptive means that the multitasking activity needs no cooperation from the executing programs. OS/2 maintains control over executing programs, and stops, or preempts, them when their time slice with the CPU is over or when a higher priority program is ready to run.
CPU scheduling is based on four priority classes-
Time Critical, Fixed-High, Regular, and Idle-Time. Each class has 32 levels of execution ordering. Scheduling parameters are user-selectable at the time the system is started or
can be varied dynamically based on system load.
Depending on a thread's priority class and level, OS/2 periodically gives each thread in each process a small slice of CPU time. Threads with higher priorities always run before threads having lower priorities. A thread runs until its time is up or until a thread with a higher priority is ready to run. At that time, OS/2 preempts the thread and starts another thread. Threads can also voluntarily relinquish the CPU (for example, by calling DosSleep).
The amount of time in each time slice is defined by the TIMESLICE command in the CONFIG.SYS file. The TIMESLICE
command can be used by the user to customize the size of the time slices that a thread gets. The default is for
OS/2 to dynamically vary the size of the time slice based on the activity of the thread and the overall system load.
When a thread is created (using DosCreateThread), it inherits the priority of the thread that started it. DosSetPriority enables threads to change their priority classes and levels in response to changes in their execution environments.
DosSetPriority enables a thread to change its own priority, or the priority of any thread within its process.
DosSetPriority also enables changing priorities for the entire process and for descendant processes. Within each class, the priority level of a thread can vary because of a DosSetPriorty request or, if dynamic priority variation is being used, because of action taken by OS/2.
=======================
PRIORITY = DYNAMIC |ABSOLUTE
Selects priority calculation in scheduling regular-class threads.
Type this command in the CONFIG.SYS file; do not enter the command at the OS/2 command prompt.
Related Commands: MAXWAIT, TIMESLICE,
The system assigns a thread based on its display status (background or foreground), recent input and output activity, and frequency of processor use. Most threads are assigned Regular priority.
Applications can adjust priorities, but the system has a built-in method of handling access to the processor. The default method is Dynamic. Changing this to Absolute can help achieve predictable results by determining the order of priority strictly on the basis of class and level.
===========================
MAXWAIT
Sets the amount of time a ready-to-run thread waits before the system assigns it a higher priority.
When a regular-class thread is denied the processor for a defined number of seconds, it receives a temporary increase in priority for a period of time up to the minimum time slice.
Note: MAXWAIT has no effect if the PRIORITY command is set to ABSOLUTE.
MAXWAIT = x
Type this command in the CONFIG.SYS file; do not enter the command at the OS/2 command prompt.
Related Commands: PRIORITY, TIMESLICE
The system limits the time that a regular-class thread waits to be processed. When the time limit is reached, the system raises the priority of the thread to give it a chance to be processed.
The most appropriate amount of time to set depends on the number of applications that must run concurrently and the kinds of activities the applications perform (the system default is three seconds). Experiment with this time to improve overall system performance.
===========================
TIMESLICE = x, y
Sets the minimum and maximum amount of processor time allocated to processes and programs for both OS/2 and DOS sessions.
Type this command in the CONFIG.SYS file; do not enter the command at the OS/2 command prompt.
Related Commands: MAXWAIT, PRIORITY
Unless a dispatching priority is explicitly defined by an application, the system assigns one to each thread of execution. The system uses round-robin (that is, time-distribution) time slicing to ensure that threads of equal priority are given equal chances to be processed.
The first value (x) in the statement is the minimum amount of time a thread can be processed before yielding the processor to a thread of the same priority level; the second value (y) is the maximum amount of time a thread can be processed before yielding processor time.
The default is dynamic time slicing based on system load and paging activity. Dynamic time slicing gives the best performance in all situations.
===========================
When
PRIORITY_DISK_IO=YES is specified in the CONFIG.SYS file, an application running in the foreground will receive disk I/O priority over applications running in the background. This means that the application in the foreground will have a better response time than applications running in the background.
===========================
дефолтная величина TIMESLICE - 32 миллисекунды для нормального приоритета, для timecritical - 8. В последних версиях и то и другое можно уменьнить до 2