rokicki@polya.Stanford.EDU (Tomas G. Rokicki) (08/30/88)
Of course for this particular application there is an easy way. He's searching for Golumb rulers, and he wants to write out the results every once in a while, say every ten minutes. So you put a statement in your main loop { static long countdown = BIGCONST ; if (--countdown <= 0) { writestate() ; countdown = BIGCONST ; } } Tune BIGCONST so updates occur every ten minutes or so. This way you don't have to worry about semaphores, timer devices, tasks, processes, or anything. Of course, it's not a general solution by any means, but there you have it. The more general solution is to spawn a task that talks turkey with the timer device. When it gets a timer message, it sets a global flag. The inner loop checks that global flag on every iteration, and if the flag is set, writes out the data and resets the flag. By the way, checking such a flag or counter is such a fast operation that it shouldn't affect the speed of your program at all. It doesn't need to be part of the innermost loop, just somewhere that is guaranteed to be seen more frequently than your update requests. If necessary, unroll a loop and only check once or twice. The flag testing alternative is two instructions: tst _checkpoint(a4) beq normalstuff jsr _writestate normalstuff: (Two instructions, that is, executed inside the inner loop.) BTW (big thrashing women), for mandlebrot type stuff, only check after every point, folks, not every time around the z^2+c, obviously. TTFN (two thrashing female nymphomaniacs) -tom