[M3devel] AlertPause(0) is alertable?

Randy Coleburn rcoleburn at scires.com
Sun Dec 13 06:16:31 CET 2009


Jay:  I never messed around much with the 3.6 code.  I purchased the 4.1 commercial version.  Prior to that we did use the DEC SRC version and that would have been the extent of my 3.6 familiarity.  After the commercial release came out, we went exclusively with Critical Mass 4.1.
Regards,
Randy

>>> Jay K <jay.krell at cornell.edu> 12/12/2009 11:56 PM >>>
Randy, Thanks. I fixed Win32 to be like that. pthreads still looks wrong.
 
 
Note that the 3.6 code doesn't seem to get it right:
 
 
PROCEDURE AlertPause(n: LONGREAL) RAISES {Alerted} =
  VAR amount, thisTime: LONGREAL;
  CONST Limit = FLOAT(LAST(CARDINAL), LONGREAL) / 1000.0D0 - 1.0D0;
  VAR self: T;
  BEGIN
    self := Self();
    amount := n;
    WHILE amount > 0.0D0 DO
      thisTime := MIN (Limit, amount);
      amount := amount - thisTime;
      WinBase.EnterCriticalSection(cm);
      InnerTestAlert(self);
      self.alertable := TRUE;
      <* ASSERT(self.waitingOn = NIL) *>
      WinBase.LeaveCriticalSection(cm);
      EVAL WinBase.WaitForSingleObject(self.waitSema, ROUND(thisTime*1.0D3));
      WinBase.EnterCriticalSection(cm);
      self.alertable := FALSE;
      IF self.alerted THEN
        (* Sadly, the alert might have happened after we timed out on the
           semaphore and before we entered "cm". In that case, we need to
           decrement the semaphore's count *)
        EVAL WinBase.WaitForSingleObject(self.waitSema, 0);
        InnerTestAlert(self);
      END;
      WinBase.LeaveCriticalSection(cm);
    END;
  END AlertPause;

The 3.6 and current user threads code seems ok, but I've not very familiar with it.
 
This might be one of those things though that's been consistently broken for so long that it's best not to depend on?
Prefer AlertPause(0.01) over AlertPause(0)??
 
 
 - Jay


 
Date: Sat, 12 Dec 2009 23:56:08 -0500
From: rcoleburn at scires.com 
To: m3devel at elegosoft.com 
Subject: Re: [M3devel] AlertPause(0) is alertable?

My understanding of the interface has always been as you suggest, namely, yes you should get an "Alerted" exception if the thread is marked alerted regardless of the value of the n (seconds) parameter.
 
Regards,
Randy

>>> Jay K <jay.krell at cornell.edu> 12/12/2009 7:37 PM >>>
If I call AlertPause with <= 0 time, should I recieve alerts?
Current pthread/win32 implementations: no.
 They say if time <= then return end before doing much.
My suspicion: yes.


Thread.i3:
 
PROCEDURE AlertPause(n: LONGREAL) RAISES {Alerted};
(* Like "Pause", but if the thread is marked alerted at the time of
   the call or sometime during the wait, raise "Alerted". *)

 
 - Jay
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20091213/20e2955c/attachment-0002.html>


More information about the M3devel mailing list