home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #3 / NN_1993_3.iso / spool / comp / sys / mac / programm / 22399 < prev    next >
Encoding:
Internet Message Format  |  1993-01-28  |  2.8 KB

  1. 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
  2. From: REEKES@applelink.apple.com (Jim Reekes)
  3. Newsgroups: comp.sys.mac.programmer
  4. Subject: Re: Closing files at interrupt time
  5. Message-ID: <REEKES-280193164916@90.10.20.67>
  6. Date: 29 Jan 93 00:49:21 GMT
  7. References: <1993Jan25.204808.11120@news.media.mit.edu> <1993Jan26.171135.13445@waikato.ac.nz>
  8. Sender: news@gallant.apple.com
  9. Followup-To: comp.sys.mac.programmer
  10. Organization: Apple Computer, Inc.
  11. Lines: 38
  12.  
  13. In article <1993Jan26.171135.13445@waikato.ac.nz>, ldo@waikato.ac.nz
  14. (Lawrence D'Oliveiro, Waikato University) wrote:
  15. > In article <1993Jan25.204808.11120@news.media.mit.edu>, delphi@media-lab.media.mit.edu (Andrew J. Kass) writes:
  16. > > I am writing a library of sound routines, but have recently run into a major
  17. > > problem. I am playing files using SndStartFilePlay asynchronously. In the
  18. > > completion routine, I set my A5 to access my globals, get the fRefNum of the
  19. > > file I was playing, and then call FSClose to close the file. The problem is,
  20. > > every now and then, not at repeatable intervals, the machine will hang during that
  21. > > call to FSClose. I can get into MacsBug and look at the stack to verify that it
  22. > > is hanging during FSClose, but any attempt to exit to shell fails and I have
  23. > > to reboot the machine.
  24. > I'd say the problem is the file system is in the middle of another call when
  25. > your interrupt routine tries to do the close. Remember, the file system
  26. > can only process one call at a time! What you should do is use PBCloseAsync
  27. > instead, which will queue the request for execution when the file system
  28. > isn't busy.
  29. > This is probably a general rule with *all* services that have an asynchronous
  30. > and a synchronous form: *never* use the synchronous form from interrupt level.
  31.  
  32. One more thing. You shouldn't call the File System from an interrupt level,
  33. even asynchronously. If the file system isn't busy, then the call will
  34. happen immediately. This also means that you're holding off interrupts
  35. until the transaction has completed since the SCSI Mgr is not asynchronous.
  36. Therefore, calling its asynch can really be synchronous. You may not hang
  37. at the interrupt, but you may hold off interrupts too long.
  38.  
  39. It's best to set a flag and perform the I/O from within the event loop, at
  40. non-interrupt level.
  41.  
  42. -----------------------------------------------------------------------
  43. Jim Reekes, Polterzeitgeist  |     Macintosh Toolbox Engineering
  44.                              |          Sound Manager Expert
  45. Apple Computer, Inc.         | "All opinions expressed are mine, and do
  46. 20525 Mariani Ave. MS: 81-KS |   not necessarily represent those of my
  47. Cupertino, CA 95014          |       employer, Apple Computer Inc."
  48.