Xref: utzoo comp.sys.mac:14178 comp.windows.misc:334 Path: utzoo!mnetor!uunet!nuchat!peter From: peter@nuchat.UUCP (Peter da Silva) Newsgroups: comp.sys.mac,comp.windows.misc Subject: Re: Preemptive and Nonpreemptive Multitasking Message-ID: <826@nuchat.UUCP> Date: 19 Mar 88 14:04:52 GMT References: <4129@hoptoad.uucp> <283@rhesus.primate.wisc.edu> <1710@ssc-vax.UUCP> <7720@apple.Apple.Com> Organization: Public Access - Houston, Tx Lines: 70 Keywords: window human computer interface In article <7720@apple.Apple.Com>, dwb@Apple.COM (David W. Berry) writes: > A quick summary of pro's and con's of preemptive and nonpreemptive > multitasking: A few comments based on the fact that you're comparing yourself to a non real-time operating system. For single-user use, a real-time operating system (like Amiga's Exec) addresses virtually every complaint you have with concurrency. > Task switches: > With non-preemptive multitasking task switches are simpler > because you know the exact state of the machine when the switch > occurs. With preemptive you're never quite sure. On a machine without memory protection, task switches can be as simple as: timer interrupt occurs in the context of the old task. push all registers on old task's stack. pop all registers off new task's stack. return in the context of the new task. > Indivisible operations: > Nonpreemptive multitasking makes indivisible operations a snap > because the program is in control of when it let's go of the processor. > With preemptive multitasking you're never sure when the processor will > go away. So you use semaphores or formal messages to synchronise things. On UNIX this is handled invisibly by the kernel: a task switch occurs under control of the operating system. On the Amiga, which has a much more complex shared memory environment, you use semaphores or use standard library calls that do the semaphoring for you. I don't care that DrawImage does WaitBlits and OwnBlits and LockLayers and stuff. > Inopportune task switches > Preemptive multitasking allows task switches at inopportune > times. Ever have your windowing system lose the processor while your > dragging something around with the mouse, makes for real jerky mouse > movement. Nope. Never had any problew3ms with that. The mouse motion is under control of a high-priority realtime task called "Intuition". > Program control > Nonpreemptive multitasking gives the program much more precise > control of when it get's switched. Not at all. I can keep from getting switched any time I need to: Forbid(); Do something that needs to be atomic. Permit(); > Fairness > Preemptive multitasking is in general "fairer" in that all > tasks have a more or less equal chance of getting processor time. > This can be modified by priorities, but no one process is going to > get all the processor. This is desireable in a multiuser timesharing > environment. It's a much less clear win in a singleuser environment > since it means that tasks that I'm not clearly interested will be > getting a fair share of the processor. If the tasks are I/O bound they'll be spending most of their time on the wait queue. If they're CPU bound you can always knock their priority down a peg. -- -- a clone of Peter (have you hugged your wolf today) da Silva `-_-' -- normally ...!hoptoad!academ!uhnix1!sugar!peter U -- Disclaimer: These aren't mere opinions... these are *values*.