Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!sdd.hp.com!spool.mu.edu!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!dkuug!imada!micro From: micro@imada.dk (Klaus Pedersen) Newsgroups: comp.sys.atari.st Subject: Re: The cause of the phantom typist Message-ID: <1991Apr3.184636.7591@imada.dk> Date: 3 Apr 91 18:46:36 GMT References: <3865050@janhh.hanse.de> Sender: news@imada.dk (USENET News System) Organization: Dept. of Math. & Computer Science, Odense University, Denmark Lines: 57 jan@janhh.hanse.de (Jan Willamowius) writes: > struct { /* GEM AES storage segment */ > .. > struct tRec /* application recording as described in Appl_tRecord() */ > { void(* t_who)(); /* routine */ > long t_how; /* arguments */ > } recs[32]; > .. > } >> void /* enqueue input for forker */ >> forkq( void(* who)(), long how) >> { reg struct tRec* rec; >> extern fpcnt, fpt; /* fork-pipe-tail index */ >> if( fpcnt < 32) >> { rec= (long )((fpt++ << 3) + &D.recs); >> if( fpt == 32) fpt= 0; >> rec->t_who= who; >> rec->t_how= how; >> fpcnt++; >> } } > (copyright by Digital Research Inc, 1985, April 15 (!)) > What happens if forkq() is called non-interrupt, the fpt index is at 31 and > the code gets reentered (interrupted) between fpt++ and if( fpt == 32) ..? You might be right there... > To exorcise one may > 1) Replace expressions like ++i; if(i == ANYPOWEROFTWO) i= 0; > by ++i &= (ANYPOWEROFTWO - 1) ????? in what language do you want to write that ????? What you are writing is : ++i = ++i & (APO2-1); - no matter how you try to hide it... But ok, I understand what you mean - what you want is a interlocked add cyclic. IAC 1,APO2,i - but no compiler can generate that to a 68K. Some signal processors can (and they are not restricted to powers of 2 (Analog Devices). > 2) make sure the interrupts are disabled whenever forkq() is called > (from chkkbd(), mchange() and ap_tplay()) This is a lot easier than making a new CPU with new instructions and a new C-like compiler that can generate them... > 3) recompile, assemble and link the system. might be hard to do with '1)'... --- Klaus (micro@imada.dk)