Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!husc6!mit-eddie!ll-xn!ames!ptsfa!ihnp4!alberta!ncc!teletron!andrew From: andrew@teletron.UUCP (Andrew Scott) Newsgroups: comp.lang.forth Subject: Re: Preventing Crashes Message-ID: <91@teletron.UUCP> Date: Fri, 24-Jul-87 12:24:03 EDT Article-I.D.: teletron.91 Posted: Fri Jul 24 12:24:03 1987 Date-Received: Sat, 25-Jul-87 17:09:29 EDT References:<629@cfa.cfa.harvard.EDU> Organization: TeleTronic Communications Ltd., Edmonton, Alta. Lines: 28 Keywords: crash user application Summary: Multitasking system structures In article <629@cfa.cfa.harvard.EDU>, willner@cfa.harvard.EDU (Steve Willner) writes: > > 4) For a multitasking system, make sure users can't do something that > hogs the CPU. Our system, for example, can only switch processes > when it encounters a ";", and all long loops must therefore contain > at least one colon-word so the process can be suspended. The > solution is to make sure that all loops defined within the > application contain a colon-word, and at the end redefine "DO", > "BEGIN", etc. so they always compile "DUM" (a no-op colon word) > within any loop a user might execute. Another technique is to allow the system to switch processes during the call to NEXT at the end of every primitive. This works especially well if NEXT is implemented as an indirect jump through an address register - just patch the register value to point to the context switching code and restore it for the next process. Then, the only restriction is to forbid primitives to use up a lot of CPU time. Also, any shared resource used by multiple processes may be accessed from within a primitve without having to use any kind of semaphores. These techniques assume that there is some kind of process scheduler. Many FORTH multitasking systems (especially process control type systems) use cooperative multitasking schemes. That is, it is up to each process to relenquish CPU control during long loops etc. This reduces quite a bit of overhead. Note that *multiuser* systems should still have some kind of scheduler to guard against runaway processes. Andrew