Re: alarm() - what am I doing wrong???



On a sunny day (Mon, 22 May 2006 17:39:35 GMT) it happened Charles Sullivan
<cwsulliv@xxxxxxxxxxxx> wrote in
<pan.2006.05.22.17.39.34.902403@xxxxxxxxxxxx>:

On Mon, 22 May 2006 09:44:37 +0000, Jan Panteltje wrote:

Cannot you use alarm_isr() to increment a variable each second,
and set a flag for main if it reaches 5?

Then have main set a flag that resets the counter in alarm_isr()
before it reaches 5 if data comes in?

Then when mai nsees the flag that 5 is reached (in your main loop),
it should do something.
?

If I'm using alarm() to count seconds, then the read() would only
be able to check for incoming data every second, no? I think I'd
lose a lot of data that way.

Not sure, maybe I undestand you wrong.
You read loop (using poll() or select(), or whatever, would run continously.
But the alrm servuice routine would only be called once a second, and
retrigger *itself*.
Normal 'clock'

static elapsed_seconds;


main()
{
// init

while(1)
{
//read input status
// if something do whatever, reset elapsed_seconds.
// else

if elapsed_seconds > 5)
{
scream TIME!!!!!

elapsed_second = 0;
}
}

// add alarm signal handler one_second_tick
alarm(1);



}


void one_second_tick()
{
elapsed_seconds++;

// re-trigger self
alarm(1);
}
.



Relevant Pages

  • Re: alarm() - what am I doing wrong???
    ... Then have main set a flag that resets the counter in alarm_isr ... You read loop or select, or whatever, would run continously. ... There are some housekeeping activities which need to be ...
    (comp.os.linux.development.apps)
  • df -kP != df -Pk
    ... It seems that -P flag to df resets previously specified -k for no good ... reason. ... Andriy Gapon ...
    (freebsd-stable)
  • Re: alarm() - what am I doing wrong???
    ... Then have main set a flag that resets the counter in alarm_isr ... If I'm using alarm() to count seconds, ... be able to check for incoming data every second, ...
    (comp.os.linux.development.apps)
  • Re: Any raw data specs for the Apple IIgs BRAM?
    ... original set of example data with the original assembly code and with ... the AppleScript, and they don't match. ... ' current value of the carry flag and then change the carry flag ... ' end of the loop ...
    (comp.sys.apple2.programmer)
  • Re: semi-timely interrupt
    ... check the flag on every RTS, LOOP, BREAK instruction. ... want to insinuate an interrupt flag check into RTS, LOOP, and BREAK ...
    (comp.programming.threads)