[M3devel] Modula-3 condition variables vs. pthread/Win32 condition variables?
Tony Hosking
hosking at cs.purdue.edu
Sun Jul 18 20:21:32 CEST 2010
On 18 Jul 2010, at 02:36, Jay K wrote:
>
> I was thinking of writing "ThreadWin6.m3".
> We'd check GetVersion and if it is >= 6.0, use it instead.
> This would give us:
> smaller locks
> condition variables
> likely isomorphic code with ThreadPThread.m3
>
>
> Question, probably a repeat: (I'll check the archives)
> Why aren't Modula-3 condition variables a thinner wrapper over pthread condition variables?
Because there is no reliable way to alert a thread waiting on a condition variable. And we need a uniform way to handshake with a thread for GC, etc. Better just to build on the per-thread CV.
> One difference I see is alert. Can't alert just signal the condition being waited on?
>
>
> Might need interlocked operations against alertable and alerted, and maybe also thread.cond?
> (Should be viable, even within one word, use the lower two bits of thread.cond?)
Again, probably not a good idea going forward -- we will ultimately build M3 mutex/CV with non-blocking primitives where possible and inflate to pthread mutex only rarely.
>
> ?
>
>
> - Jay
>
>
>
>
>
More information about the M3devel
mailing list