[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "Real" Multitasking (Re: GNO questions...)
In article <C5wGAo.M8G@CAM.ORG> vandry@CAM.ORG (Phillip Vandry) writes:
>
> You don't see progrms for preemptive multitaskers implementing
> cooperatie multitasking because it has advantages in soe situations.
> That's because it doesn't.
Boy, I just love these flame wars. People start making blanket
statements and everyone else gets annoyed.
The company that I work for produces a data communications system
(remote data collection, and display at a central site).
Communication is via radio, telephone, or land lines.
In the current version of this system, I wrote all of the code in the
modules which perform communication between the master & remote sites.
The remote communicator module is performing about six somewhat
interconnected tasks (communicating with the master station,
monitoring I/O modules, running downloaded programs, transferring data
around internally, etc.)
The entire module involves shared access to a large number of
variables. Writing this with pre-emptative multitasking would have
been a nightmare - there are too many cross-associations between the
various data structures for it to work efficiently.
Code space is extremently limited (32k, which is now full), and using
pre-emptative multitasking would have made the program too large.
Time-critical operations are handled by interrupt routines (such as
serial I/O, timing generation, etc.)
I decided to use cooperative multitasking, in which each process
manually relinquishes control by calling a 'defer' routine. This is
only done when system variables are in a stable state. Interrupt
handlers have limited access to system variables, and semaphore
techniques are used to handle data sharing with these, and in
situations where something is left in an unstable condition over a
'defer' call.
The same cooperative multitasking scheme is used in the master station.
In my opinion, cooperative multitasking is very useful for
multi-threaded applications, which are doing many unrelated tasks
which involve sharing access to variables.
If several independent programs are running, cooperative multitasking
has few benefits over pre-emptative multitasking.
--
David Empson
dempson@swell.actrix.gen.nz <--- Note my new E-Mail address!
Snail mail: P.O. Box 27-103, Wellington, New Zealand