[comp.sys.mac.programmer] Time Slicing?

kenc@vaxb.acs.unt.edu (05/27/91)

I'm wondering if it's possible to make a system call from a VBL task?

Can anyone help me out on this one?

What I'm thinking of is trying out a little experiment (Yes, and probably
crashing the machine), to hook a time slicer into the vbl list, and (sort of)
providing preemptive multitasking....

Any Ideas?

(Yes, and for those special people out there, flames are welcome...;)

-- 
\  Ken Corey, VAX/Unix Programmer/Operator  (And GOD am I confused...;)  /
 \          kenc@vaxb.acs.unt.edu  ken@isect.lonestar.org               /

trebor@lkbreth.foretune.co.jp (Robert J Woodhead) (05/28/91)

kenc@vaxb.acs.unt.edu writes:

>I'm wondering if it's possible to make a system call from a VBL task?

>Can anyone help me out on this one?

It's certainly possible to make a system call from a VBL.  The problem
is that it's almost certain that it will crash your machine.  The
root cause is that many (all?) of the ROM routines are not re-entrant,
so if a program happens to be in ROM routine X when your VBL gets
control, and it calls X, then when the program resumes, it may
very well go blotto bigtime.

This situation may have changed in the roms on the newer machines,
but don't bet on it.  Besides, this means your program wouldn't be
portable to some Macs.

Somewhere in IM or the tech notes there is a list of routines that
cannot be called from INITs.  The list of routines that cannot be
called from VBL's is a superset of this list.  Exactly what this
superset is is unknown, and subject to change with each new version
of roms and system software.

In short -- DONT DO IT!

-- 
+--------------------------------------------------------------------------+
| Robert J. Woodhead, Biar Games / AnimEigo, Incs.   trebor@foretune.co.jp |
| "The Force. It surrounds us; It enfolds us; It gets us dates on Saturday |
| Nights." -- Obi Wan Kenobi, Famous Jedi Knight and Party Animal.         |

kenc@vaxb.acs.unt.edu (05/28/91)

In article <9376@lkbreth.foretune.co.jp>, trebor@lkbreth.foretune.co.jp (Robert J Woodhead) writes:
> kenc@vaxb.acs.unt.edu writes:
> 
>>I'm wondering if it's possible to make a system call from a VBL task?
> 
>>Can anyone help me out on this one?
> 
> Somewhere in IM or the tech notes there is a list of routines that
> cannot be called from INITs.  The list of routines that cannot be

The problem is these routines are based strictly on the fact that they use the
memory manager...I'd like to know what I can and can't do from a VBL....;)

\  Ken Corey, VAX/Unix Programmer/Operator  (And GOD am I confused...;)  /
 \          kenc@vaxb.acs.unt.edu  ken@isect.lonestar.org               /

kire@cyklop.nada.kth.se (Jan-Erik M}ngs) (05/28/91)

In article <1991May27.150858.47099@vaxb.acs.unt.edu> kenc@vaxb.acs.unt.edu writes:
  I'm wondering if it's possible to make a system call from a VBL task?

  What I'm thinking of is trying out a little experiment (Yes, and probably
  crashing the machine), to hook a time slicer into the vbl list, and (sort of)
  providing preemptive multitasking....

Don't try "system calls" but you can hook a time slicer into the
vbl-list and do your own multitasking, this is the way Minix on
the Mac does its preemptive multitasking. But remember, there is
no documentation on how the stack looks like from a
VBL-interrupt, so I would not recommend it if you care about
portability (don't even think about it on A/UX).  But for fun,
yes it's possible. 

	Kire (kire@nada.kth.se)