<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
Randy, Thanks. I fixed Win32 to be like that. pthreads still looks wrong.<BR>
<BR>
<BR>
Note that the 3.6 code doesn't seem to get it right:<BR>
<BR>
<BR>
PROCEDURE AlertPause(n: LONGREAL) RAISES {Alerted} =<BR> VAR amount, thisTime: LONGREAL;<BR> CONST Limit = FLOAT(LAST(CARDINAL), LONGREAL) / 1000.0D0 - 1.0D0;<BR> VAR self: T;<BR> BEGIN<BR> self := Self();<BR> amount := n;<BR> WHILE amount > 0.0D0 DO<BR> thisTime := MIN (Limit, amount);<BR> amount := amount - thisTime;<BR> WinBase.EnterCriticalSection(cm);<BR> InnerTestAlert(self);<BR> self.alertable := TRUE;<BR> <* ASSERT(self.waitingOn = NIL) *><BR> WinBase.LeaveCriticalSection(cm);<BR> EVAL WinBase.WaitForSingleObject(self.waitSema, ROUND(thisTime*1.0D3));<BR> WinBase.EnterCriticalSection(cm);<BR> self.alertable := FALSE;<BR> IF self.alerted THEN<BR> (* Sadly, the alert might have happened after we timed out on the<BR> semaphore and before we entered "cm". In that case, we need to<BR> decrement the semaphore's count *)<BR> EVAL WinBase.WaitForSingleObject(self.waitSema, 0);<BR> InnerTestAlert(self);<BR> END;<BR> WinBase.LeaveCriticalSection(cm);<BR> END;<BR> END AlertPause;<BR><BR>
The 3.6 and current user threads code seems ok, but I've not very familiar with it.<BR>
<BR>
This might be one of those things though that's been consistently broken for so long that it's best not to depend on?<BR>
Prefer AlertPause(0.01) over AlertPause(0)??<BR>
<BR>
<BR>
- Jay<BR><BR><BR> <BR>
<HR id=stopSpelling>
Date: Sat, 12 Dec 2009 23:56:08 -0500<BR>From: rcoleburn@scires.com<BR>To: m3devel@elegosoft.com<BR>Subject: Re: [M3devel] AlertPause(0) is alertable?<BR><BR>
<STYLE>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Verdana;}
</STYLE>
<DIV>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.</DIV>
<DIV> </DIV>
<DIV>Regards,</DIV>
<DIV>Randy<BR><BR>>>> Jay K <jay.krell@cornell.edu> 12/12/2009 7:37 PM >>><BR>If I call AlertPause with <= 0 time, should I recieve alerts?<BR>Current pthread/win32 implementations: no.<BR> They say if time <= then return end before doing much.<BR>My suspicion: yes.<BR><BR><BR>Thread.i3:<BR> <BR>PROCEDURE AlertPause(n: LONGREAL) RAISES {Alerted};<BR>(* Like "Pause", but if the thread is marked alerted at the time of<BR> the call or sometime during the wait, raise "Alerted". *)<BR><BR> <BR> - Jay<BR></DIV> </body>
</html>