<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Verdana
}
--></style>
</head>
<body class='hmmessage'>
[again, expect a bounce, but the mail does get through]<BR>
<BR>
<BR>
Tony, for Interix, suspend/resume thread can be achieved writing to a file.<BR>
Getting a suspended thread's registers can be gotten reading from a file.<BR>
(I believe the same thing works on Solaris.)<BR>
It appears to be intended for debuggers.<BR>
I can see that it works well.<BR>
I doubt that a thread's context is on a signal handler's stack.<BR>
I propose:<BR>
<BR>
<BR>
ActState = { Starting, Started, Stopping, Stopped };<BR> REVEAL Activation = UNTRACED BRANDED REF RECORD<BR> frame: ADDRESS := NIL; (* exception handling support *)<BR> handle: pthread_t := NIL; (* LL = activeMu; thread handle *)<BR> statusFile: int := -1; (* for Interix *)<BR> controlFile: int := -1; (* for Interix *)<BR> (* C code knows the structure above this point *)<BR>...<BR>
END;<BR><BR>
<BR>
ThreadPThread.h:<BR>
<BR>
<BR>
typedef struct _Activation_t {<BR> void* frame;<BR> void* pthread;<BR> int statusFile; /* for Interix */<BR> int controlFile; /* for Interix */<BR>} Activation_t;<BR><BR>
<BR>
and then whereever we pass act.handle off to C code, pass act instead.<BR>
<BR>
<BR>
frame is kept first so that it is offset 0 in case that gives codegen efficiencies<BR>
on the often used push/popframe.<BR>
The other three are moved up to the top to reduce maintainence of ThreadPThread.h.<BR>
<BR>
<BR>
I assume "branding" doesn't introduce data in the record.<BR>
I'd have to check the codegen to verify frame is at offset 0.<BR>
<BR>
<BR>
#ifdef code will open the files.<BR>
Modula-3 code can check if the files are >= 0 and close them,<BR>
or it can be a call out to #ifdefed C.<BR>
<BR>
<BR>
An alternative is that wherever we pass act.handle, also pass act.statusFile and act.controlFile.<BR>
(as VAR for initialization).<BR>
That is less fragile and less extensible.<BR>
I'm fine with that approach too.<BR>
<BR>
<BR>
As well though, I was wondering, maybe we should have:<BR>
<BR>
<BR>
common/InterixThreadState.i3<BR>
T = RECORD END; (* zero size? *)<BR>
<BR>
<BR>
interix/InterixThreadState.i3<BR>
T = RECORD statusFile, controlFile := -1; END;<BR>
<BR>
<BR>
and then put InterixThreadState.T in Activation.<BR>
That way saving the other platforms from spending the space.<BR>
Just two integers, not much, but in principle..<BR>
(We also sometimes use up 8 bytes for the pthread_t when 4 would suffice,<BR>
on 64bit platforms with pthread_t == int, I think HP-UX is like that at least.)<BR>
<BR>
<BR>
I could also open/close the files for every suspend/resume/processStopped,<BR>
though that seems too lame.<BR>
<BR>
<BR>
Another idea, that I don't really like, is to never optimize and<BR>
ignore the registers and just use the stack.<BR>
I rarely optimize, but depending on that seems bad.<BR>
<BR>
<BR>
Your "safe points" proposal would also make this work, though<BR>
I'd rather not wait for that.<BR>
<BR>
<BR>
?<BR>
<BR>
Ok to add the two integers all the time?<BR>
Ok to either depend on the record layout in C, or to always pass the integers around?<BR>
<BR>
<BR>
Thanks,<BR>
- Jay<BR> </body>
</html>