Re: POSIX Timers on Linux 2.4



Kasper Dupont wrote:

Hi Kasper,

> Josh Birnbaum wrote:
> >
> > The code follows. Any feedback re the above is welcome.
>
> I have no experience with POSIX timers, but I did notice
> a few bugs in the way you handle signals.
>
> >
> > if( timer_settime( timerOne, 0, &spec, NULL ) != 0 )
> > {
> > perror( "timer: ERROR: timer_settime" );
> > exit( EXIT_FAILURE );
> > }
> >
> > if( sigaction( SIGINT, &sigAct, NULL ) != 0 )
> > {
> > perror( "timer: ERROR: sigaction" );
> > exit( EXIT_FAILURE );
> > }
>
> You should install the handler earlier. A signal handler
> need to be installed before you perform the action which
> will cause a signal to be send. Though it is highly
> unlikely, it is theoretically possible, that you are
> preempted just before the sigaction call and then don't
> get the CPU again before the signal fires.

Yes, I had thought about my placement of the sigaction() call
relative to timer_create() and timer_settime. I am now exper-
imenting with calling sigaction() earlier in my code.

> >
> > for( ;; )
> > {
> > intr = 0;
> >
> > pause();
> >
> > if( intr )
> > {
> > printf( "caught SIGINT\n" );
> > }
> > }
>
> There are multiple race conditions in this code.

Ah, thanks for this feedback. You're referring specifically to
signals race conditions?

Thanks,

Josh.

P.S. Apologies re the multi post. I had already posted by the time
I noticed it.

> --
> Kasper Dupont -- Rigtige mænd skriver deres egne backupprogrammer
> #define _(_)"d.%.4s%."_"2s" /* This is my new email address */
> char*_="@2kaspner"_()"%03"_("4s%.")"t\n";printf(_+11,_+6,_,6,_+2,_+7,_+6);
.



Relevant Pages

  • Re: What did that thread indicate?
    ... >> approach to pattern recognition that uses a strictly feed-forward, ... Signals from the sesnory cortex feed directly into sequence memory ... >lots and lots of feedback for image recognition), ... >reinforcement learning system), ...
    (comp.ai.philosophy)
  • Re: Patterns as codes
    ... detect certain codes that are signaled using line curvatures. ... That is one way how a higher organisational level sends feedback to ... The feedback pathways are in general massive, ... when you think about it you see the signals in these pathways ...
    (comp.ai.philosophy)
  • Re: exhaustive definition in the life sciences - an oxymoron?
    ... >Both pathways are part of the cerebral cortex, ... >a 3rd central visual pathway, but it has largely been overtaken by the ... the act of thinking) but does this mean that same signals ... Retina-muscle feedback signals carry depth cues. ...
    (comp.ai.philosophy)
  • Re: Norton noiseless feedback amp calculation
    ... My thought was that it had to be be better than a 560 ohm resister in the ... to be added to the filter insertion loss. ... Feedback has the advantage of added ... linearity reducing other undesired products of ajacent and large signals. ...
    (sci.electronics.design)
  • Re: Norton noiseless feedback amp calculation
    ... My thought was that it had to be be better than a 560 ohm resister in the ... to be added to the filter insertion loss. ... Feedback has the advantage of added ... linearity reducing other undesired products of ajacent and large signals. ...
    (sci.electronics.design)