<html><head><base href="x-msg://1743/"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I really dislike this... just for a broken platform...<div><br></div><div><div><div><span class="Apple-style-span" style="border-collapse: separate; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><span class="Apple-style-span" style="border-collapse: separate; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; -webkit-text-decorations-in-effect: none; text-indent: 0px; -webkit-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div><font class="Apple-style-span" color="#0000FF" face="'Gill Sans'"><span class="Apple-style-span" style="font-size: medium;">Is there really no way to know that the context on is not on the stack somewhere?</span></font></div><div><font class="Apple-style-span" color="#0000FF" face="'Gill Sans'"><span class="Apple-style-span" style="font-size: medium;"><br></span></font></div><div><span class="Apple-style-span" style="font-size: medium; ">On 16 Dec 2009, at 10:36, Jay K wrote:</span></div></span></span></span></span></span></span></span></span></div></span></span></div><div><br class="Apple-interchange-newline"><blockquote type="cite"><span class="Apple-style-span" style="border-collapse: separate; font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-border-horizontal-spacing: 0px; -webkit-border-vertical-spacing: 0px; -webkit-text-decorations-in-effect: none; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><div class="hmmessage" style="font-size: 10pt; font-family: Verdana; ">[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></div></span></blockquote></div><br></div></div></body></html>