[M3devel] Latest ThreadPThread

Tony Hosking hosking at cs.purdue.edu
Tue Apr 21 07:05:48 CEST 2009


On 21 Apr 2009, at 14:44, Jay wrote:

> The Interlocked doesn't have a strong reason.
> It's fairly cheap at least.

It's many cycles (~50x depending on hardware) more expensive than an  
unlocked INC/DEC.

> There are places in the Modula-3 code with comments about inc/dec  
> taking one instruction,
> which these would but otherwise I'm skeptical..

I'm pretty sure that is only in the user-level threading model, where  
thread switches only occur on delivery of a signal to the process. I  
am unaware of any OS/hardware that will deliver a thread switch signal  
in the middle of INC/DEC.  So, effectively, for user level threads INC/ 
DEC can be assumed atomic.  That's what the comments are meant to  
imply.   Outside ThreadPosix, all other uses of INC/DEC manipulate  
state that is already protected appropriately by a lock so should be  
thread safe.

>
>
>
>  - Jay
>
>
>
> From: hosking at cs.purdue.edu
> To: hosking at cs.purdue.edu
> Date: Tue, 21 Apr 2009 11:58:31 +1000
> CC: m3devel at elegosoft.com; jay.krell at cornell.edu
> Subject: Re: [M3devel] Latest ThreadPThread
>
> Jay, I am curious why you are using atomic operations for INC and  
> DEC of inCritical (on WIN32/WIN64).  In general, they are protected  
> by an appropriate lock, so I don't know what the need is.  Are you  
> trying to move towards lock-free implementations of some of the  
> thread primitives?
>
> Antony Hosking | Associate Professor | Computer Science | Purdue  
> University
> 305 N. University Street | West Lafayette | IN 47907 | USA
> Office +1 765 494 6001 | Mobile +1 765 427 5484
>
>
>
> On 21 Apr 2009, at 11:53, Tony Hosking wrote:
>
> Jay,
>
> I have some questions about why you have moved the Activation  
> declaration to C code.  I'm not sure what this gains, and I have  
> strong reasons for wanting to keep it in Modula-3.  I'd like to  
> revert these most recent changes if possible, unless you can say why  
> you want to retain them.  Perhaps you have a good reason, but I  
> remain to be convinced.
>
> -- Tony
>
> Antony Hosking | Associate Professor | Computer Science | Purdue  
> University
> 305 N. University Street | West Lafayette | IN 47907 | USA
> Office +1 765 494 6001 | Mobile +1 765 427 5484
>
>
>
>
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090421/52597138/attachment-0002.html>


More information about the M3devel mailing list