[M3devel] (no subject)

Jay K jay.krell at cornell.edu
Mon Sep 7 11:33:39 CEST 2009


Tony, can you..um, trick question sort of, briefly explain the differences between pthreads and Modula-3 threads?
The "trick" part is that, to an audience (me) who is not all that familiar with the nuances of either?
I'll see if I can find my green book and other reference material (online).


I understand the basics of threading very well, if that helps.
Eh, not much to it really.


I'm not super familiar with condition variables, as Win32 didn't historically have them.
But I think I understand them.


Specific questions:
  Can Modula-3 threads be implemented more directly upon pthreads?


  Why do we need to maintain a waiting list?


  Is "alert" the same as "cancel" in pthread vocabulary? Or almost the same?


  I understand..there might be a difficult problem..does Modula-3 allow catching an alert? I think so.
  Does Posix allow canceling a cancel? I think not.


  Posix allows, what I think of as try/finally, for alert. Modula-3 probably does too. Even though you can't stop the cancel, you can run "cleanup" code that runs before the cancel completes.


However mapping Modula-3 to Posix here would be tricky. As I see things..any function with a try/finally would have to be contorted into a form that passes a pointer to itself, along with parameters, to C code that does pthread_cleanup_push/pop around calling the function pointer. At least given the Darwin implementation. Other implementations might simply be able to call push at the start and pop at the end. But on Darwin these functions are macros where push introduces a local variable that pop references. I guess maybe one could to the "reverse engineering" approach (just by reading the header). But it'd still be ugly.


I have to do more research here.


I'm seriously consider "writing" a ThreadPThreadDirect.m3 that is thinner than the current ThreadPThread.m3 and see how it fairs, specifically if the Juno hangs go away.
"writing" being an exaggeration because it should be very small.


Thanks,
 - Jay

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://m3lists.elegosoft.com/pipermail/m3devel/attachments/20090907/71370f9e/attachment-0001.html>


More information about the M3devel mailing list