Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Modula 2 > Solved: [TS3.10...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 2 Topic 300 of 383
Post > Topic >>

Solved: [TS3.10] Multithreading problem

by "Peter Engels" <p.engels@[EMAIL PROTECTED] > Sep 29, 2006 at 10:18 PM

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!
 




 2 Posts in Topic:
[TS3.10] Multithreading problem
"Peter Engels"   2006-09-27 19:28:45 
Solved: [TS3.10] Multithreading problem
"Peter Engels"   2006-09-29 22:18:28 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sun Oct 12 15:56:22 CDT 2008.