On Wed, 27 Sep 2006 19:28:45 +0200 (MSZ), Peter Engels wrote:
>This works very well, if only one process is waiting for input, but it
>will obviously not work, with two or more processes, because it is not
>clear, whether the event belongs to the calling process or not. Any
>ideas to solve this problem in an easy way?
>
The problem is solved so far, perhaps someone else is interested, so
here is a possible solution, that works fine for me:
The module SYSTEM contains an undo***ented procedure
PROCEDURE CurrentProcess() : ADDRESS;
which can be used to solve the problem. I have changed the procedure
GetEvent to use the procedure CurrentProcess:
PROCEDURE GetEvent (VAR Event : EVENT);
VAR OldProc : ADDRESS;
BEGIN
Lock;
OldProc := ProcAdr;
ProcAdr := CurrentProcess();
Unlock;
LOOP
WAIT (sEventAvailable);
Lock;
IF ProcAdr = CurrentProcess () THEN
Event := PopEvent ();
ProcAdr := OldProc;
Unlock;
RETURN
END;
Unlock;
Delay (0);
END
END GetEvent;
where ProcAdr is a global variable in the module containing GetEvent
and is initialized to NIL.
MfG / Regards
Peter Engels
--
This OS/2 system uptime is 01 hours, 28 minutes and 14 seconds.
Please use the reply-to address for e-mails!


|