home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!pageworks.com!world!eff!sol.ctr.columbia.edu!spool.mu.edu!olivea!apple!goofy!mumbo.apple.com!gallant.apple.com!NewsWatcher!user
- From: REEKES@applelink.apple.com (Jim Reekes)
- Newsgroups: comp.sys.mac.programmer
- Subject: Re: Closing files at interrupt time
- Message-ID: <REEKES-280193164916@90.10.20.67>
- Date: 29 Jan 93 00:49:21 GMT
- References: <1993Jan25.204808.11120@news.media.mit.edu> <1993Jan26.171135.13445@waikato.ac.nz>
- Sender: news@gallant.apple.com
- Followup-To: comp.sys.mac.programmer
- Organization: Apple Computer, Inc.
- Lines: 38
-
- In article <1993Jan26.171135.13445@waikato.ac.nz>, ldo@waikato.ac.nz
- (Lawrence D'Oliveiro, Waikato University) wrote:
- >
- > In article <1993Jan25.204808.11120@news.media.mit.edu>, delphi@media-lab.media.mit.edu (Andrew J. Kass) writes:
- > > I am writing a library of sound routines, but have recently run into a major
- > > problem. I am playing files using SndStartFilePlay asynchronously. In the
- > > completion routine, I set my A5 to access my globals, get the fRefNum of the
- > > file I was playing, and then call FSClose to close the file. The problem is,
- > > every now and then, not at repeatable intervals, the machine will hang during that
- > > call to FSClose. I can get into MacsBug and look at the stack to verify that it
- > > is hanging during FSClose, but any attempt to exit to shell fails and I have
- > > to reboot the machine.
- >
- > I'd say the problem is the file system is in the middle of another call when
- > your interrupt routine tries to do the close. Remember, the file system
- > can only process one call at a time! What you should do is use PBCloseAsync
- > instead, which will queue the request for execution when the file system
- > isn't busy.
- >
- > This is probably a general rule with *all* services that have an asynchronous
- > and a synchronous form: *never* use the synchronous form from interrupt level.
-
- One more thing. You shouldn't call the File System from an interrupt level,
- even asynchronously. If the file system isn't busy, then the call will
- happen immediately. This also means that you're holding off interrupts
- until the transaction has completed since the SCSI Mgr is not asynchronous.
- Therefore, calling its asynch can really be synchronous. You may not hang
- at the interrupt, but you may hold off interrupts too long.
-
- It's best to set a flag and perform the I/O from within the event loop, at
- non-interrupt level.
-
- -----------------------------------------------------------------------
- Jim Reekes, Polterzeitgeist | Macintosh Toolbox Engineering
- | Sound Manager Expert
- Apple Computer, Inc. | "All opinions expressed are mine, and do
- 20525 Mariani Ave. MS: 81-KS | not necessarily represent those of my
- Cupertino, CA 95014 | employer, Apple Computer Inc."
-