Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

_os_sleep issue

12 views
Skip to first unread message

Jer

unread,
Nov 3, 2009, 9:21:02 AM11/3/09
to
Hi All,
I am making a project for college where I must create pipes, send
messages, after x seconds print the message and after y seconds send
the message to a new process on a different pipe. Each process is send
and receiving the messages successfully but when I try to write a
startup and enter the timing's some messages are not send. I am trying
to use:

TimeToDelay = 600;
TimeToPrint = 325;
{
//When I want to print the message I am entering:
_os_sleep(&TimeToPrint,&dummysignal);

//Then when I want to send it I simple delay the process by using:
_os_sleep(&TimeToDelay,&dummysignal);

There is 5 processes and the startup must fork them. Is there
something wrong with my sleep syntax or what is the probable cause of
the issue?

Regards,
Jer

Ian Goldby

unread,
Nov 4, 2009, 4:56:06 AM11/4/09
to
It's hard to say much from the small fragment of code you gave, but
here are a few general comments.

1. _Always_ check the return value whenever you call an _os_*()
function. If you get an error you need to handle that error.

2. Remember that _os_sleep() wakes early if the process gets a signal.
(If you don't have a signal handler the process will be terminated, so
you must have a signal handler.) Always put _os_sleep() in a loop so
that the full sleep time is completed even if it gets woken by a
signal.

3. Consider using alarms rather than timed sleeps.

4. Pipes show up in the filing system with the path /pipe/<name>. You
can use shell functions like dir -e to examine what pipes have been
created, and look at their contents with dump. A pipe will continue to
exist until all the data has been read from it, so if you have pipes
lying around it means the reader hasn't completed its task.

Please let us know how you get on. By sharing your answer you
encourage other people to make suggestions.

Message has been deleted
0 new messages