archives

general thread model motivations?

About the purpose of threads — especially green threads — I would like to hear suggestions about models, metaphors, terminology, or tactics about why this form of code organization is a good idea. A very high-level, hand-wavy perspective is what I hope to explore, to inform docs one might write for new users of code who ask simply, "But why?" If anyone wants to contribute, I'll also post short comments too, though I'm more interested in what other folks think. Note other ways of organizing code amount to the same thing, just folded differently; for example, coroutines are just green threads by another name and focus, at least in broad terms.

I've been thinking about green threads all the time lately, outside work, imagining diagrams and prose to explain the point, as starting context to motivate a library architecture whose VM model revolves around green threads (and groups of them associated under one identity in simulation of a green process). Working on solutions for a long time can make one focus too hard on the answer, and not enough on the question; so I hope I can get folks to ask rhetorical questions that amount to vague problem statement(s) causing one to seek a thread oriented design.

Ideas I had earlier this evening got profoundly vague as I tried to generalize. I suspected thread use causes hierarchy flattening, and simplifies by making many complex things uniform in organization. Another half-formed idea likened thread use to a kind of indirection, but a flat top-level indirection, with threads as equal peers. You see I'm trying to squint and find really coarse form and structure here.

Here's one last anecdote for entertainment's sake. I'm not sure what year it was — maybe 1996? — but I had a chance to ask Ike Nassi at Apple what he thought needed to be done for Dylan to gel/progress/matriculate/etc, because he was in charge of the Dylan group and I thought he might have a view from on high. He surprised me by saying he wished Dylan had defined a thread model. My first reaction was, "What does that have to do with anything?" But now I get it. So I wonder what I didn't grasp then, which I learned since, that makes the difference.