writing alarm function

Discussion in 'C Programming' started by Greg, Jan 16, 2008.

  1. Greg

    Greg Guest

    I am writing some code for a kernel of a board that does not contain
    the alarm function call. I would like to use it so I am trying to
    duplicate its functionality. Basically what I have is inside my alarm
    function I create a new thread that sleeps for the time passed in and
    then raises SIGALRM. I am using this to try and interrupt a recvfrom
    call by basically creating a timeout using this alarm function. Does
    anyone know a better way to do this or am I doing this? PS...I don't
    have setitimer either with the kernel. :(
     
    Greg, Jan 16, 2008
    #1
    1. Advertising

  2. On 16 Jan 2008 at 0:43, Greg wrote:
    > I am writing some code for a kernel of a board that does not contain
    > the alarm function call. I would like to use it so I am trying to
    > duplicate its functionality. Basically what I have is inside my alarm
    > function I create a new thread that sleeps for the time passed in and
    > then raises SIGALRM. I am using this to try and interrupt a recvfrom
    > call by basically creating a timeout using this alarm function. Does
    > anyone know a better way to do this or am I doing this? PS...I don't
    > have setitimer either with the kernel. :(


    And the baying hounds are loosed in 3... 2... 1...
     
    Antoninus Twink, Jan 16, 2008
    #2
    1. Advertising

  3. Greg

    ppi Guest

    On Jan 15, 7:43 pm, Greg <> wrote:
    > I am writing some code for a kernel of a board that does not contain
    > the alarm function call. I would like to use it so I am trying to
    > duplicate its functionality. Basically what I have is inside my alarm
    > function I create a new thread that sleeps for the time passed in and
    > then raises SIGALRM. I am using this to try and interrupt a recvfrom
    > call by basically creating a timeout using this alarm function. Does
    > anyone know a better way to do this or am I doing this? PS...I don't
    > have setitimer either with the kernel. :(


    I am afraid your question is out of topic in this newsgroup. You may
    want to try a newsgroup related to your particular kernel:
    implementing the alarm() call in unlikely to be safely/rightly
    implemented using only the C library (remember that C doesn't know
    anything about recvfrom/threads and their supposed interaction with
    SIGALRM).

    If you are using recvfrom you'd better check for a (supposedly
    available ?) timeout option when creating your socket or check you
    select() system call with a timeout option, and do the recvfrom() only
    when somtehing is available for this socket i.e. the fd is readable.
    Of course everything written previously is a waste of time since you
    don't even provide info on the kernel you are using and way out of
    topic here :)

    cheers,
    Paulo
     
    ppi, Jan 16, 2008
    #3
  4. Greg

    Greg Guest

    On Jan 15, 5:31 pm, ppi <> wrote:
    > On Jan 15, 7:43 pm, Greg <> wrote:
    >
    > > I am writing some code for a kernel of a board that does not contain
    > > thealarmfunction call.  I would like to use it so I am trying to
    > > duplicate its functionality.  Basically what I have is inside myalarm
    > > function I create a new thread that sleeps for the time passed in and
    > > then raises SIGALRM.  I am using this to try and interrupt a recvfrom
    > > call by basically creating a timeout using thisalarmfunction.  Does
    > > anyone know a better way to do this or am I doing this?  PS...I don't
    > > have setitimer either with the kernel. :(

    >
    > I am afraid your question is out of topic in this newsgroup. You may
    > want to try a newsgroup related to your particular kernel:
    > implementing thealarm() call in unlikely to be safely/rightly
    > implemented using only the C library (remember that C doesn't know
    > anything about recvfrom/threads and their supposed interaction with
    > SIGALRM).
    >
    > If you are using recvfrom you'd better check for a (supposedly
    > available ?) timeout option when creating your socket or check you
    > select() system call with a timeout option, and do the recvfrom() only
    > when somtehing is available for this socket i.e. the fd is readable.
    > Of course everything written previously is a waste of time since you
    > don't even provide info on the kernel you are using and way out of
    > topic here :)
    >
    > cheers,
    > Paulo


    Many thanks. Select was what I was looking for. That accomplished
    it. I am using the Xilinx kernel. Sorry for the mystery. Thanks for
    the reply.
     
    Greg, Jan 16, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. service

    alarm workaround

    service, Nov 6, 2003, in forum: Perl
    Replies:
    0
    Views:
    596
    service
    Nov 6, 2003
  2. Tim Zych

    Authentication with Zone Alarm?

    Tim Zych, Jan 11, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    326
    Tim Zych
    Jan 11, 2004
  3. honcho
    Replies:
    0
    Views:
    447
    honcho
    Jun 24, 2005
  4. Ole Weigelt

    Greenhorn Alarm

    Ole Weigelt, Sep 15, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    424
  5. dutche
    Replies:
    13
    Views:
    540
    Kenny McCormack
    May 4, 2010
Loading...

Share This Page