Re: Signal() emulation

From: Andrew Valencia <vandys_at_nospam.org>
Date: Wed Apr 05 1995 - 08:11:42 PDT

[Ronald Oussoren <roussor@cs.vu.nl> writes:]

>Sigsuspend() is used to wait for a signal. Currently I
>have implemented this using busy waiting. Is there a
>system call to wait for the delivery of an event, and
>if not, is there a reason for not having it?

I believe you can do a timed wait for a LONG time, and the system call will
be interrupted on receipt of an event.

>The other problem is alarm(). Alarm() should make provisions
>for the (async) generation of a SIGALRM signal after a number
>of seconds. This part is easy: just fork of a thread that
>sleeps that number of seconds and then sends the event.
>However, calling alarm() should also cancel the outstanding
>timer, and return the number of seconds until the canceled
>timer would cause a signal. How can this be done from
>user space?

You'll need to kill off the thread handling the alarm sending. If you keep
the time when alarm() was called, you can get the current time and figure
out what time remains.

>While I am asking questions, why doesn't tfork() allow
>passing a parameter to the new thread? Wouldn't having
>this ability make it easier to create thread-safe code
>(no need for a global variable to pass data to the new
>thread, like in the implementation of rename()).

Yes, and this actually came by the list one time. I proposed it, but the
general response was muted so I never went ahead. I think I'll add it for
1.4.

                                                        Andy
Received on Wed Apr 5 07:24:55 1995

This archive was generated by hypermail 2.1.8 : Thu Sep 22 2005 - 15:12:27 PDT