[LLVMdev] Proposal: stack/context switching within a thread

Jeffrey Yasskin jyasskin at google.com
Mon Apr 12 09:21:39 PDT 2010


On Mon, Apr 12, 2010 at 6:15 AM, Kenneth Uildriks <kennethuil at gmail.com> wrote:
> I created a wiki at http://code.google.com/p/llvm-stack-switch/
>
> Right now I just copied and formatted the document as-is... I'll go
> back over it with your comments in mind soon.  One more question,
> which you can answer here or there:
>
>> Point 4 is a bit confusing. Normally, it's fine for a thread to share
>> some of its stack space with another thread, but your wording seems to
>> prohibit that.
>
> Really?  How does that work?

void thread1() {
  Foo shared_var;
  queue.send(&shared_var);
  int result = otherqueue.recv();
  return;
}

void thread2() {
  Foo* shared_var = queue.recv();
  otherqueue.send(work_on(shared_var));
}

is legal with posix threads. It's just illegal to return out of a
function while its stack space is used by another thread. I've seen
this used inside a condition variable implementation, among other
places.

>> I'll forward your next draft back to the stackless folks, unless you
>> want to pick up the thread with them.
>
> If you're willing to be the go-between, I really appreciate it..  I
> don't think I have the time to really get involved with Stackless
> Python, especially as I would have to learn regular Python first.

Sure.




More information about the llvm-dev mailing list