发明名称 Efficient resumption of co-routines on a linear stack
摘要 Unsuspended co-routines are handled by the machine call stack mechanism in which the stack grows and shrinks as recursive calls are made and returned from. When a co-routine is suspended, however, additional call stack processing is performed. A suspension message is issued, and the entire resume-able part of the call stack is removed, and is copied to the heap. A frame that returns control to a driver method (a resumer) is copied to the call stack so that resumption of the co-routine does not recursively reactivate the whole call stack. Instead the resumer reactivates only the topmost or most current frame called the leaf frame. When a co-routine is suspended, it does not return to its caller, but instead returns to the resumer that has reactivated it.
申请公布号 US9003377(B2) 申请公布日期 2015.04.07
申请号 US201012683447 申请日期 2010.01.07
申请人 Microsoft Technology Licensing, LLC 发明人 Gafter Neal M.;Torgersen Mads;Meijer Henricus Johannes Maria;Gustafsson Niklas
分类号 G06F9/44 主分类号 G06F9/44
代理机构 代理人 Drakos Kate;Minhas Micky
主权项 1. A system comprising: a processor and a memory including a module configured to cause the processor to: suspend and resume co-routines comprising a calling co-routine and a called co-routine in a computer environment utilizing a single linear machine call stack not inherently capable of suspending and resuming co-routines, wherein only in response to detecting suspension of the called co-routine, the module: saves a resume-able portion of the single linear machine call stack not previously saved to a heap that emulates the single linear machine call stack but is separate from the single linear machine call stack such that the resume-able portion of the single linear machine call stack is only copied to the heap once, the resume-able portion of the single linear machine call stack comprising a stack frame for the calling co-routine, a stack frame for the called co-routine and a stack frame for a resumer; removes the resume-able portion of the single linear machine call stack from the single linear machine call stack; places a return address for a resumer that controls co-routine execution on the single linear machine call stack so that when the called co-routine is suspended it does not return to the calling co-routine but instead returns to the resumer; and in response to detecting resumption of the called co-routine: copies only the stack frame for the called co-routine onto the single linear machine call stack without copying all of the resume-able portion of the single linear machine call stack onto the single linear machine call stack.
地址 Redmond WA US