Path: utzoo!utgpu!attcan!uunet!lll-winken!lll-lcc!ames!mailrus!uwmcsd1!ig!agate!ucbvax!hplabs!well!ewhac From: ewhac@well.UUCP (Leo L. Schwab) Newsgroups: comp.sys.amiga Subject: Re: Sample Exception Handler Summary: Caveats Message-ID: <6637@well.UUCP> Date: 27 Jul 88 10:04:48 GMT References: <3447@louie.udel.EDU> Reply-To: ewhac@well.UUCP (Leo 'Bols Ewhac' Schwab) Organization: Bleep Gzorp! Lines: 36 Quote: "There's no time in space! Hold on! FLOOR IT, SULU!" -- Portnoy In article <3447@louie.udel.EDU> iphwk%MTSUNIX1.BITNET@cunyvm.cuny.edu (Bill Kinnersley) writes: >Well, I guess I answered my own question out of necessity. Here is >my attempt at writing an Exception Handler. [ ... ] > [ code deleted ] Congratulations, you got it. I would recommend that you also restore the tc_ExceptCode pointer when done as well; it may be important to someone. There are some caveats that you should be aware of. Kickstart does not internally interlock asynchronous operations. When you enter a Kickstart routine, the routine assumes that it will run to completion before returning to you. Thus, certain Kickstart routines may procure some resources upon entry, and free them upon exit. If you interrupt them and don't return, Bad Things will happen. As an example, suppose you call Draw(). Draw() calls OwnBlitter(), then performs weird sex on the blitter to draw the lines. If, during this time, your exception routine gets called, and your exception routines calls exit() or longjmp(), or in any way fails to return back to where it came from, you will have left the blitter allocated (since Draw() never got a chance to call DisownBlitter()). If you exit(), the system will appear to stop, since no one can get control of the blitter again. Similar situations exist in DOS. As long as your exception routine returns without trying to re-route the execution thread, you can use exceptions safely. However, be very careful of interrupting Kickstart routines; weird things may happen. You may wish to look at Matt Dillon's Qint routines which help alleviate this problem. _-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_-_ Leo L. Schwab -- The Guy in The Cape INET: well!ewhac@ucbvax.Berkeley.EDU \_ -_ Recumbent Bikes: UUCP: pacbell > !{well,unicom}!ewhac O----^o The Only Way To Fly. hplabs / (pronounced "AE-wack") "Hmm, you're right. Air is made up of suspended meat loaf." -- Josh Siegel