[Stackless] Question about channels

Russ Cox rsc at plan9.bell-labs.com
Wed Oct 16 22:24:11 CEST 2002


> Being a simulator, I could do this in any imaginable way possible and not 
> using stackless at all. But since I want to learn how to use stackless and 
> channels, I'd just want to get a feel for their usage.
> Somehow (and that might be really a misconception on my part), channels 
> remind me of sockets and I'd like to use channels in exactly that way.
> Lets say, I'd like to model a node as a tasklet that listens on two (virtual) 
> network cards. For every network card (or probably better: for every IP 
> address) I'd take a pair of channels, listen to the receiving ones and take 
> appropriate routing action on the received data. In order to do that, the 
> channels have to be nonblocking.
> I'd just like to make my model as primitive as possible.
> 
> But then, maybe my question shows that I really don't know what I'm talking 
> about.

This would in fact be my first choice, but it requires an alt statement.
The problem is you have n channels and you want to wait
for input over any one of them.  Non-blocking channel operations
don't get you anything here, since you'd have to busy loop
waiting for them.

What you could do instead is make a tasklet for each interface
and have it just read packets from the interface channel and send
the pair (packet, interface-channel) to the per-node channel.
Then the interesting node loop reads the per-node channel
which tells it both the packet and which channel the packet
came from.  This simulates the alt, more or less.

Russ

_______________________________________________
Stackless mailing list
Stackless at www.tismer.com
http://www.tismer.com/mailman/listinfo/stackless



More information about the Stackless mailing list