[M3devel] (no subject) Threads Primitives

Daniel Alejandro Benavides D. dabenavidesd at yahoo.es
Mon Sep 7 17:30:52 CEST 2009


Hi all:
Please consider this reading:  "Synchronization Primitives
for Threads" which has a formal definition and proof for threads
primitives: 
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.34.1092
and  "Pthreads and Applications of Mutex-Abstraction"
http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.33.5367
Also
the formal definition of the thread Interface from DEC SRC research
Report 20 (revised in the Green book, Systems programming with Modula-3
as  Chapter 5): 
ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/abstracts/src-rr-020.html

and 
an introduction to programming with Threads DEC SRC research Report 35
(revised in the Green book, Systems programming with Modula-3 as 
Chapter 4)
ftp://gatekeeper.research.compaq.com/pub/DEC/SRC/research-reports/SRC-035.pdf

Hope it helps


--- El lun, 7/9/09, Jay K <jay.krell at cornell.edu> escribió:

De: Jay K <jay.krell at cornell.edu>
Asunto: [M3devel] (no subject)
Para: "Tony" <hosking at cs.purdue.edu>, "m3devel" <m3devel at elegosoft.com>
Fecha: lunes, 7 septiembre, 2009 4:33




#yiv792797967 .hmmessage P
{
margin:0px;padding:0px;}
#yiv792797967 {
font-size:10pt;font-family:Verdana;}

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/abb2095e/attachment-0002.html>


More information about the M3devel mailing list