Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!samsung!munnari.oz.au!comp.vuw.ac.nz!windy!sramtrc From: sramtrc@windy.dsir.govt.nz Newsgroups: comp.unix.aux Subject: Re: Why doesn't this simple two line program work (solved) Message-ID: <18796.2788d333@windy.dsir.govt.nz> Date: 7 Jan 91 19:59:47 GMT References: <18794.2783c5b2@windy.dsir.govt.nz> <47721@apple.Apple.COM> Reply-To: sramtrc@albert.dsir.govt.nz Organization: DSIR, Wellington, New Zealand Lines: 41 >>What am I doing wrong? > > You aren't calling WaitNextEvent, EventAvail, or any of the other traps > which give control back to MultiFinder and allow CommandShell to run. > > Bob Lantz > A/UX Team Thanks, Bob, for making me Multifinder aware. I read up on MultiFinder and I have a rough understanding of it now and I got the program running. My problem was (actually my real problem is that I'm a UNIX programmer not a MacOS one) that I thought that the example qdsamp.c in /mac/src was MultiFinder-correct and when I used its event loop I still got the same blocking on write. So I figured it was not a MultiFinder problem. Also I thought that setting noEvents = 1 avoids the need for event stuff. The problem with the qdsamp.c is that it uses the value zero for the sleep parameter in WaitNextEvent. Zero ticks is not enough time to let Commandshell do the printing. It is necessary to use a value of about 5 or more. The tricky part is that if the value is not large enough then eventually the deficit will accumulate and the program will hang again. So you have to have a large value for safety and that means extra time is wasted while being asleep. Funny stuff. I couldn't get it to work using EventAvail - it didn't give Commandshell enough time. MultiFinder is weird - a program can hog the cpu even while it is asleep. But I can see a use for that type of multitasking in UNIX. When a window system is running it should be able to grab as much cpu time as it needs and only let other processes use its idle time. Then window response is always the same speed and other process don't suffer since the window system is still using the same number of cpu seconds per minute as it was under preemptive multitasking. I wonder how System 7 does it. I guess I should invest in some copies of Inside Mac and the A/UX Toolbox manual (I have the 1.0 and 1.1 manuals but it was getting too expensive to shell out for a third manual set). I have always thought that the Mac was a fascinating machine. Now with the UNIX kernel underneath it it is even more so. Tony Cooper sramtrc@albert.dsir.govt.nz