Path: utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!oliveb!amiga!kodiak From: kodiak@amiga.UUCP (Robert R. Burns) Newsgroups: comp.sys.amiga.tech Subject: Re: CIA Timer Example Message-ID: <3227@amiga.UUCP> Date: 30 Dec 88 20:48:17 GMT References: <1439@percival.UUCP> <5587@cbmvax.UUCP> <38@sdcc10.ucsd.EDU> Reply-To: kodiak@tooter.UUCP (Robert Burns) Distribution: na Organization: Commodore-Amiga Inc, Los Gatos CA Lines: 36 In article ... (John Schultz) writes: 1) oldint := AddICRVector(CIAicrTB,timer,CIAResource^); 2) IF oldint # NIL THEN (* Not available? Take it by force! *) 3) RemICRVector(CIAicrTB,oldint^,CIAResource^); 4) IF AddICRVector(CIAicrTB,timer,CIAResource^) # NIL THEN (* Install ours *) 5) WriteString("AddICRVector Failed.\n");(*What?! This should never happen*) Unfortunately, there was no smiley face to calm me down. Who is served in a multitasking environment by this kind of holier-than-thou, stab-them-in-the-back programming mentality? Certainly not the user! The Amiga has a few hardware resources which can be allocated by applications that need them. If they're already in use, do one of several things: 1. Steal them, as above. *No!* 2. Die mysteriously. *No!* 3. Take the ln_Name of the oldint and present it to the user as an indication of what program precludes you from running. *Yeah!* a. *That's* why oldint was returned. b. *That's* why filling in the ln_Name field of structures is useful. c. *That way* the user is not mystified why one or the other of his applications went bust. Remember multitasking! See what happens when, between line 3 & line 4 above, another task gets cycles and follows the rules? Why *shouldn't* it happen? Remember multitasking! It imbues a special responsibility on Amiga programmers to think harder and code better, so that one's goofs do not cause another's application to appear buggy -- soiling the wrong reputation. - Kodiak -- Bob Burns, amiga!kodiak _ | /_ _|. _ | Commodore __ |_) _ |_ _ )' |<(_)(_)|(_\|< /\ | ||| _` /\ |_)(_\| )(_\ | | \ Software ___/..\|\/|||__|/..\___ Faith