Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!tut.cis.ohio-state.edu!ucbvax!husc6!encore!zelig.encore.com From: jdarcy@zelig.encore.com (Mostly Harmless) Newsgroups: comp.arch Subject: Re: Macintosh OS (was: 68000 and Workstations.) Message-ID: <11964@encore.Encore.COM> Date: 25 May 90 17:41:07 GMT References: <37@voa3.UUCP> Sender: news@Encore.COM Lines: 55 ck@voa3.UUCP (Chris Kern): > For those of use who don't have any experience with the Mac OS, could > someone explain what its deficiencies are with respect to multitasking? > Is it that the OS doesn't do time-slicing? Does a context switch have > to wait for some event at the application level? How is multitasking > implemented? Apple's term for it is "cooperative multitasking". Most Mac applications spend the bulk of their time in an event loop, in which they repeatedly call GetNextEvent() until something happens and then they branch all over the place according to the event type. What MultiFinder basically does is steal control from the running application on the third unsuccessful return from GetNextEvent. Thus you are correct: context switching is in fact done only by the (implied) consent of the current program. A program that gets stuck in a tight infinite loop and that never calls GetNextEvent will hang the system. Most people are probably aware that Desk Accessories aren't multitasking either. Basically they're implemented as drivers and they get events by an unusual method. When the foreground application gets an event it has to check which window the event occurred in; if that window is not one of its own it explicitly passes the event to a Toolbox routine, which in turn passes it on to the appropriate desk accessory. It is trivial for an application to "steal" desk accessory events by simply not bothering to pass them on, though this is considered "antisocial". In fact, there is a mechanism by which a driver (and hence a DA) can arrange to be run every N ticks (1/60 second), but this also depends on the application calling the Toolbox periodically, at which point the countdown timer is checked and drivers are awakened if >N ticks have elapsed. There are two other ways in which the Mac OS fails to meet what most consider minimum requirements for true multitasking. One is memory management. The Mac OS basically doesn't do address translation and everything runs in the MC68K's Supervisor mode. This means that an errant application not only *can* but usually *will* overwrite memory that doesn't belong to it. Of course, the toolbox itself is in ROM, but all system globals are vulnerable, as are other applications. Lastly, there's the lack of IPC. This is being addressed by Apple's Inter-Application Communication facilities (about which I know very little since they were barely around when I stopped doing Mac stuff), but I don't see anything comparable to pipes, sockets, mailboxes, message queues or even signals. Any communication between entities under the Mac OS is basically done on a "roll-your-own" basis. I hope this helps people understand the claims about the Mac OS's status as a platform for multitasking. If it seems that I've gone into undue detail I apologize. Jeff d'Arcy, Generic Software Engineer - jdarcy@encore.com Nothing was ever achieved by accepting reality