Newsgroups: comp.sys.mac.system
Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!sdd.hp.com!news.cs.indiana.edu!bronze!tagreen
From: tagreen@bronze.ucs.indiana.edu (Todd A. Green)
Subject: Re: Preemption good, time-slicing bad (was Re: All about sys 7.0 <long>)
Message-ID: <1991Apr1.232302.6882@bronze.ucs.indiana.edu>
Organization: Indiana University, Bloomington
References: <1CE00001.bmpkbkz@tbomb.ice.com> <10227@hub.ucsb.edu>
Date: Mon, 1 Apr 91 23:23:02 GMT
Lines: 60

In article <10227@hub.ucsb.edu> doner@henri.UUCP (John Doner) writes:
>In article <1CE00001.bmpkbkz@tbomb.ice.com> time@ice.com writes:
> [articles debating multitasking deleted]
>
>I don't believe the current Mac OS allows for priorities among running
>processes, but I don't see any reason why this feature couldn't be
>implemented.  It's simply a matter of withholding events from the
>application until the OS decides to release them.
>

I concur that right now there is no way for the user to give a program
priority, but since when you call WaitNextEvent() you pass as one of
its arguments a value that will tell your app how many ticks you are
willing to give up before gaining the cpu back, I don't see why it
would be that hard to implement this.

I'm still relatively new at programming the Mac, but wouldn't this
seem like a logical solution: You can declare your sleep time
parameter to be a variable and then give the user a way of changing
the amount of ticks that s/he wants the application to give up. (At
least it's one that I've put into all my (whopping 4 ;) ) programs
I've written.  This could be in the form of a slidebar in a dialog
box, a simple pull down menu item, or whathaveyou.  Now wouldn't it be
even better (IMO) if Apple where to implement this at the system
level, say perhaps when you called "About the Finder" (or it could
have it's own dialog box) instead of just giving you the apps that are
running, their memory usage etc., you also had an option to change the
amount of ticks the apps would give up.  This way there would be a
common interface for developers and users alike.  A macintosh version
of the "nice" command in Un*x.

Also on another side note, someone said earlier that all programs that
are running in the background get the same amount of time, yet no one
contested it.  This is not true as I understand it, and would really
like to be corrected if I am wrong. (Probably should go home and read
IM again...but I do have that Portuguese paper due *sigh* ).  It's my
understanding that apps in the "background" get a time slice and then
perform whatever routines they want and then release the cpu again.
Thus if I check for context switching (via app4 event right?) and see
that I've been switched out to the background I can be a "nice"
programmer and change my sleep parameter to give up say 10 ticks
before trying to regain the cpu, whereas when I get switched back into
the foreground (and yes I know this language is vague and there are
different kinds of context switches, but I hope I've made myself
clear) then I can use more cpu time setting my sleep value to 0L,
since I am the application that would probably need the most
attention.  Of course this depends on exactly what type of application
you are writing etc...but these are just general thoughts.  My main ?
is that even though you've been switched out that does not mean that
all of a sudden you get the same amount of time as all other apps
correct?

Todd
-----
Internet:
tagreen@bronze.ucs.indiana.edu
NeXTMail:
tagreen@lothario.ucs.indiana.edu


