SCOUG OS/2 For You - October 1993
Experimenting with Multitasking
by Michael Lavender
What is multitasking? Is it configurable to my computer? Is it necessary
to do so? Will I see an improvement? I'll try to answer these questions. I
had some of them myself when I first installed OS/2.
Multitasking is when the computer is running two or more applications
"at the same time". Unless you are running multiple CPUs (Centeral
Processing Unit), each with its own application, you are not running
applications simultaneously. On the other hand, the slowest computer able
to run OS/2 runs at 2.5 MIPS (million instructions per second), and that's
pretty fast. Unless you can type a half of a million words per second, you
are wasting CPU time while running a word processor. OS/2 takes these
empty spaces in which the CPU is waiting for you to press a key, and runs
some other application. Thus, from your point of view, the computer is
running two or more applications at the same time.
How OS/2 divides the CPU's time is what makes it configurable. All
programs and threads of the programs are viewed by OS/2 as processes. OS/2
prioritize between processes. The processes are divided into classes and
then sub-divided into deltas. There are three classes with 3 as the
highest, but unless you are part of a network or have a mission critical
application all of you programs are class 1 or 2 (probably 2, but I'm just
guessing). All of the CPU's processing goes to the highest class process,
ignoring any process with a lower class. If, however, all of the processes
of the highest class are waiting for input, then OS/2 blocks them out and
the processes of the next highest class are allowed CPU time, until the
input that the higher class process was waiting for comes in. This is
called event multitasking, since waiting for I/O events drive the
task-switching process.
Deltas separate the processes in the same class the same way classes are
separated. If a process has a higher delta then other processes of the
same class, that process gets all the CPU time until idle. It is allowable
to change the delta of an OS/2 application (assuming the programmer makes
such action available to the user). An example of this can be found in the
Spooler Settings Notebook (which is in the System Setup folder). The Print
Priority tab shows a slider bar and a value box. The slider bar goes from
1 to 189. Since there are 63 deltas per class, this means you have the
ability to set the printer from class 1, lowest delta to class 3, highest
delta.
Under the descriptions of deltas and classes, I implied that OS/2
multitasks when the process with the highest class or delta is idle. What
happens when a process constantly uses CPU time? Does multitasking stop?
It depends on how you have set up your CONFIG.SYS file. There are three
lines in your CONFIG.SYS that control multitasking: PRIORITY, MAXWAIT, and
TIMESLICE. PRIORITY can equal ABSOLUTE or DYNAMIC. With PRIORITY =
ABSOLUTE, a process that constantly uses CPU time stops multitasking dead
in its tracks , because the delta of a process never changes. With
PRIORITY=DYNAMIC, the processes that have been inactive during a certain
interval have their deltas increased by one. When the delta of a process
is equal to the delta of the constantly running process, the inactive
process gets the chance to use the CPU. After that chance, the process'
delta is returned to normal. MAXWAIT sets the interval noted above in
seconds. Thus if MAXWAIT=5, then if a process has been idle for 5 seconds,
then its delta is increased by one. Finally, TIMESLICE fixes the minimum
and maximum time a process uses the CPU in milliseconds. None of this
makes any difference if the processes are divided by class. Increasing the
deltas has no effect on a process' class.
Now, to add another wrinkle to this system. When OS/2 stops a process in
order to let another process access to the CPU, it must make a record of
the CPU's contents at the moment OS/2 stopped the first process. The speed
in which that takes depends on how fast is your computer. If it takes more
time then is set for a timeslice, then you are spending more time
switching between processes then you are running the applications. You end
up with system that appears slow. If, on the other hand, you make the
times lice too high, then the system spends too much time on any one
process and the system runs in fits and starts.
You can test how your system multitasks by writing and running a program
(say in REXX or Qbasic) that counts. An example:
/* REXX counter */
count=0
do 1000
count=count+1
say "Number is now " count
end
Open up two OS/2 Windows. Type the name of the program in each window.
Start the programs as close to each other as possible, and then click on
the mouse at a point on the Desktop. This makes it so that neither program
gets priority. Run the programs with one of them as the active window
(which means it has priority and is never idle). Change the settings in
the CONFIG.SYS for comparison tests (you must shutdown and reboot after
each change in the CONFIG.SYS file).
All this is the equivalent of benchmark tests (unrealistic with only
peripheral comparisons to real life), but will help you in determining the
settings needed for your day to day activities. The settings for a
486DX-50Mhz for optimal performance will be different then the settings
for my 386-40Mhz or the settings for a 386SX.
*Note: Most of the information was cribbed from "Inside OS/2 2.0" by
Minasi, Little, etal.
The Southern California OS/2 User Group
P.O. Box 26904
Santa Ana, CA 92799-6904, USA
Copyright 1993 the Southern California OS/2 User Group. ALL RIGHTS
RESERVED.
SCOUG is a trademark of the Southern California OS/2 User Group.
OS/2, Workplace Shell, and IBM are registered trademarks of International
Business Machines Corporation.
All other trademarks remain the property of their respective owners.
|