🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.os.mach
Article #913

Interrupting a msg_receive from another thread

#913
From: Jeremy Epstein
Date: Mon, 01 Apr 1991 16:50
37 lines
2064 bytes
Environment: Running Mach 2.5 on a Sun 3, using the cthreads library.

I've got a server with three threads.  Clients send this server
receive rights on two ports, one for normal messages and one for
critical messages.

In the server, one thread (call it A) sits and builds up a port set (by
collecting receive rights for the normal messages), and also selects one
of the critical ports to be the focus port.  The second thread (thread B)
reads messages from the port set consisting of all of the normal ports.
The third thread (thread C) reads from the current focus port only.

There are two problems here: First, the port set may increase (new ports
may be added by thread A) while thread B is doing a msg_receive()).
Second, thread A may choose a different focus port while thread C is
doing a msg_receive().

In the first case, I can overcome the problem by periodically waking
up from the msg_receive (i.e., use a timeout) and select the port set
again [or will the port_set_add() in thread A automatically cause the
msg_receive in thread C to see messages which arrive on the new port?]
In the worst case, I'd wait a big longer than I need before I receive
a message from the new port.  This isn't too serious.

However, in the second case I could receive a message from a port which
is no longer the focus port.  This turns out to be undesirable.

The question [finally!]: Is there any reasonable way for thread A to
wake thread C from its msg_receive()?

Thanks for any suggestions!
--Jeremy
-- 
Jeremy Epstein			UUCP: uunet!trwacs!epstein
Trusted X Research Group	Internet: epstein@trwacs.fp.trw.com
TRW Systems Division		Voice: +1 703/876-8776
Fairfax Virginia
Technical Details
Message-ID: <283@trwacs.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!trwacs!epstein

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!samsung!uunet!trwacs!epstein
From: epstein@trwacs.UUCP (Jeremy Epstein)
Newsgroups: comp.os.mach
Subject: Interrupting a msg_receive from another thread
Message-ID: <283@trwacs.UUCP>
Date: 1 Apr 91 16:50:27 GMT
Organization: TRW Systems Division, Fairfax VA
Lines: 37