writing alarm function

G

Greg

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. :(
 
A

Antoninus Twink

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...
 
P

ppi

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
 
G

Greg

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,268
Messages
2,571,095
Members
48,773
Latest member
Kaybee

Latest Threads

Top