Shirley <novice@hongkong.com> wrote:
Suppose I use a while loop to let server keep on receiving from and
replying message to its clients.
If the server ignore the worker1’s Msgsend( ) in the 1st loop and let
worker1 enter the block state, and server keep on receiving other Msgsend()
by other workers in the following loop, how can the server “wake up” worker1
again latter?
Since worker1 is already in block state, it won’t be able to send signal to
server again. Even the server implement MsgReceive() in next loop, it won’t
receive signal from worker1…
If you are going to delay replaying to a particular client, then you need
to save the rcvid that matches the MsgSend that you are leaving blocked
until later. Once it is time to reply, just MsgReply() to the saved
rcvid, and you will wake up the client.
e.g.
while(1)
{
rcvid = MsgReceive( … )
// error checking
switch (msg.type )
{
case reply_now:
MsgReply( rcvid, … )
break;
case reply_later:
save_rcvid = rcvid;
break;
case later:
MsgReply( save_rcvid, … )
MsgReply( rcvid, … )
break;
}
}
Of course, if you might have several block workers (clients), then
you couldn’t just use a simple save_rcvid variable, it would be
more like:
add_rcvid_to_list( rcvid, why );
And:
unblock_rcvid = find_rcvid_in_list( why );
-David
QNX Training Services
http://www.qnx.com/support/training/
Please followup in this newsgroup if you have further questions.