Skip to content
Tcl Source Code Ticket Change Details
Login

Ticket Change Details

Overview

Artifact ID: 2febdac6e9d1625c55a73664f804d2b134a34cb5fcce231a52a9135fdb634acc
Ticket: cc592ec70de012dff030d61affb4b8d62da6cfb6
vwait not NRE-enabled: C stack busy
User & Date: sebres on 2018-04-16 18:16:47
Changes

  1. icomment:
    Another problem with yield across vwait/update etc is - event-cycle does not belong to the single interpreter.
    
    Theoretically one thread can have multiple interpreters (for example I myself have such systems e. g. with N workers * K interpreters), so despite I don't use coroutines resp. NRE-tailcalls across main-cycle, I would not like to use compiled vwait/update version, because it may cause unexpected (or rather unclear) flow-interruptions within single vwait's across multiple interpreters.
    
    Let alone it may not help in such case: I don't know how good such constructs will work within different TEBCResume segments.
    I'll try to explain:
    <code><verbatim>
      I1 -> vwait ...
         ... DoOneEvent -> any event of I2
            I2 -> update ...
               ... DoOneEvent -> I1-yield is due 
                   **BOOM (C stack busy) **
    </verbatim></code>
    So instead of NRE-callback resp. compiled version of vwait/update I can imagine a new interp-state like yieldInProgress, which can freeze execution of the interpreter (yield callback TclNRCoroutineActivateCallback) until the C call stack of it gets the same stackLevel. So it may be something like this:
    
    <code><verbatim>
    TEBCResume:
      I1 -> vwait ...
         ... DoOneEvent -> I1-yield is due:
               if C stack is busy:
                   set I1.yieldInProgress to current callBack and return TCL_YIELD.
               ...
         ... if I1.yieldInProgress add callbacks and return to TEBCResume.
      <-
      execute yieldInProgress callbacks (we can, because interp == I1 and C-stack is clear)
      continue vwait-callbacks (e. g. wait further / timeouts, etc.).
    
    </verbatim></code>
    
  2. login: "sebres"
  3. mimetype: "text/x-fossil-wiki"