Newsgroups: comp.sys.amiga.programmer
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!mintaka!geech.gnu.ai.mit.edu!rjc
From: rjc@geech.gnu.ai.mit.edu (Ray Cromwell)
Subject: Re: Lemmings - a tutorial Part IV
Message-ID: <1991Apr11.172802.20661@mintaka.lcs.mit.edu>
Sender: news@mintaka.lcs.mit.edu
Organization: The Internet
References: <8496@crash.cts.com> <JPC.91Apr11115750@terra.fct.unl.pt>
Date: Thu, 11 Apr 91 17:28:02 GMT
Lines: 71

In article <JPC.91Apr11115750@terra.fct.unl.pt> jpc@fct.unl.pt (Jose Pina Coelho) writes:
>
>In article <8496@crash.cts.com> uzun@pnet01.cts.com (Roger Uzun)
>writes: 
>
>   Yes but anything you can think of to do with a game, can be done
>   in an OS legal manner, and since many people have A3000's,A2500's etc
>   you cannot say any particular game will iuse 99% of the CPU.
>
>Yes, but for that the OS *must* have real-time extensions, something
>that will allow it to give the program all the Cpu it needs for the
>time it needs.
>
>The program says
>
>	PrivateCPU(ON);	
>	SpeedCheck();	/* make sure you have the correct speed */
>	PrivateCPU(OFF);
>
>	Request(time);	
>
>	PrivateCPU(ON);		/* The game is master */
>	while(1) {
>	  GameCycle();
>   	  ReleaseCpu(time);	/* The game is magnanimous and allow
>				the OS to schedule other programs,
>                                but the program counter MUST be here
>				again after time*uSeconds is elapsed */
>	}
>
>   The point is the only thing that OS friendly and legal programming
>   practice costs you is memory (and the time to read the RKM's etc,
>   but given the use of source level debuggers and the enforcer,your
>   development task is simpler if you keep the OS around)
>
>Yes, but if the OS schedules the mail spooler in the middle of a
>dogfight, it'll be one hell of a hiccup.
>
>Maybe on WB 3.0, we get a real time extension, to allow games to be
>smooth without ejecting the OS.
>
>BTW, real-time extensions are quite hard to add, they must be
>superbely designed to avoid constant locking.

  I'm not an expert on the internals of Exec, but as far as I know, the
Amiga's scheduling is REAL-TIME. For instance, in the included example,
PrivateCPU(ON) could be written as a macro for Forbid, or SetTaskPri.
#define ON 100
#define OFF 0
#define PrivateCPU(pri) SetTaskPri(FindTask(NULL),pri)

  ReleaseCPU(time) would be coded as a request to the timer.device, then
it would merely Wait() for the timer to complete the request.
If the OS schedules a mail spooler after ReleaseCPU() it won't matter.
Exec will wake up your task (put the mail spooler to sleep) as soon
as the timer request finishes. That's why the AmigaOS is real-time.
Perhaps you it confused with UNIX.

>--
>Jose Pedro T. Pina Coelho   | BITNET/Internet: jpc@fct.unl.pt
>Rua Jau N 1, 2 Dto          | UUCP: ...!mcsun!unl!jpc
>1300 Lisboa, PORTUGAL       | Home phone: (+351) (1) 640767
>
>- If all men were brothers, would you let one marry your sister ?


--
/~\_______________________________________________________________________/~\
|n|   rjc@albert.ai.mit.edu   Amiga, the computer for the creative mind.  |n|
|~|                                .-. .-.                                |~|
|_|________________________________| |_| |________________________________|_|
