Oberon Community Platform Forum
November 19, 2019, 06:42:24 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Active oberon paper - is it correct?  (Read 3294 times)
alys
Newbie
*
Posts: 26


« on: March 19, 2008, 10:45:27 PM »

in paper I found -
http://bluebottle.ethz.ch/languagereport/node8.html#SECTION00084000000000000000
method unlock of this obect is not completely correct. or no?

  ReentrantLock* = OBJECT
    VAR
      lockedBy: PTR;
      depth: LONGINT;
   
    PROCEDURE Lock*;
    VAR  me: PTR;
    BEGIN {EXCLUSIVE}
      me := AosActive.CurrentThread();
      AWAIT((lockedBy = NIL) OR (lockedBy = me));
      lockedBy := me;
      INC(depth)
    END Lock;
   
    PROCEDURE Unlock*;
    BEGIN {EXCLUSIVE}
      (*might should be added?*)
     IF lockedBy#AosActive.CurrentThread() THEN Error("...."); RETURN; END;
      IF lockedBy=NIL THEN Error("..."); RETURN; END;
      (*original text*)
      DEC(depth);
      IF depth = 0 THEN lockedBy := NIL END
    END Unlock;
   
  END ReentrantLock;

else any thread can unlock any lock??
« Last Edit: March 19, 2008, 11:00:00 PM by alys » Logged
staubesv
Administrator
Sr. Member
*****
Posts: 387



« Reply #1 on: March 20, 2008, 09:00:58 AM »

This depends on what you consider correct: This implementation assumes the Unlock is only called by threads that successfully acquired the lock. But you're right: Any other thread could call Unlock without having acquired the lock.

The implementation of re-rentrant locks used in AOS (Locks.RecursiveLock) does the check, however.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!