On Sat, Feb 14, 2004 at 06:53:44AM -0500, [EMAIL PROTECTED] wrote:
> 
> Taking Chris' question further... why not implement wait queues (I'm
> thinking along the lines of NT). Any session could declare it's interest
> on a waitable object... and anyone with a reference to that object could
> call wakeup on it. SIGCHLD handling is therefore just a special
> case of this - you have a handle on the process, register you want to wait
> on it. When the pid dies, the object referring to that PID could get a
> wakeup event. If the waitqueue is empty, the process vaporises in a puff
> of logic. Else the sessions that declared interest get woken.

I've been skimming the web about wait queues, and they're mostly
kernel and driver synchronization things.  The web seems to think
they're more a Linux dealie than an NT one, and the name "wait queue"
seems synonymous to "channel" in other UNIXy operating systems.

I'm also confused by process going away when a wait queue is empty,
although as I write this I suppose "empty wait queue" means nothing
has subscribed interest to the process.

So I'm going to list what I think you're saying about wait queues,
with some code that illustrates my understanding of them so far.  Your
job, should you choose to accept it, is to explain where I'm off.

So.

Sessions would create wait queue instances rather than use Kernel
methods to watch resources.

  $heap->{fh_watcher} =
    WQueue::File->new($handle, "r", "event", @optional_etc);

instead of

  $kernel->select_read($handle, "event", @optional_etc);

and

  delete $heap->{fh_watcher};

instead of

  $kernel->select_read($handle);

Sessions stay around as long as they have at least one wait queue.

Wait queues are a form of IPC.  Other sessions can trigger them if
they can find a reference to them.

  $global{23} = WQueue::Event->new("event");

and another session can trigger that with

  $global{23}->enqueue(@parameters);

which would replace

  $kernel->post(23 => event => @parameters);

Signals would work similarly, but the OS would call enqueue().

  $heap->{sigint_queue} = WQueue::Signal->new(INT => "event");

Alarms:

  my $before_you_go_go = time() + 3600;
  $heap->{wake_me_up} = WQueue::Alarm->new($before_you_go_go);

and other stuff.

-- 
Rocco Caputo - [EMAIL PROTECTED] - http://poe.perl.org/

Reply via email to