[Stackless] RE: ALT vs. KQueue? (was: Asyncronous IO)

Christian Tismer tismer at stackless.com
Fri Jan 9 15:39:34 CET 2004

Tom Locke wrote:

>>   http://www.kegel.com/c10k.html
> Thanks for that.
>>I was thinking about a way to mediate between an ALT
>>(especially the vector ALT, found in Limbo assembly code)
>>and FreeBSD's KQueue approach.
>>My idea is to build more primitive code for Stackless,
>>which is able to support ALT, and KQueue like structures
>>as well.
> I'm not familiar with this 'vector alt', and google for 'limbo "vector
> alt"' gave nothing. Could you explain that a bit?

Vitanuova has all the documents. The root is here:

The Limbo assembler is defined here:


The Limbo language has the ALT statement in its
general form, but also a simplified vector form.

See Dennis Ritchie's paper on the LÖimbo language:

Secitom 9.8 explains the ALT statement. At the end of
the paragraph, there is:
As mentioned in the specification of the channel receive operator <- in 
§8.2.8, that operator can take an array of channels as an argument. This 
notation serves as a kind of simplified alt in which all the channels 
have the same type and are treated similarly. In this variant, the value 
of the communication expression is a tuple containing the index of the 
channel over which a communication was received and the value received.

This corresponds to the implementation of the ALT opcode
in DIS:

alt - Alternate between communications

Syntax:		alt	src, dst

The alt instruction selects between a set of channels ready to 
communicate. The src argument is the address of a structure of the 
following form:

struct Alt {
	int nsend;		/* Number of senders */
	int nrecv;		/* Number of receivers */
	struct {
		Channel* c;		/* Channel */
		void*	val;	/* Address of lval/rval */
	} entry[];

The vector is divided into two sections; the first lists the channels 
ready to send values, the second lists channels either ready to receive 
or an array of channels each of which may be ready to receive. The 
counts of the sender and receiver channels are stored as the first and 
second words addressed by src. An altinstruction proceeds by testing 
each channel for readiness to communicate. A ready channel is added to a 
list. If the list is empty after each channel has been considered, the 
thread blocks at the alt instruction waiting for a channel to become 
ready; otherwise, a channel is picked at random from the ready set.

The alt instruction then uses the selected channel to perform the 
communication using the val address as either a source for send or a 
destination for receive. The numeric index of the selected vector 
element is placed in dst.

I had the impression that the vector alt might be somewhat
similar to KQueues.

ciao - chris
Christian Tismer             :^)   <mailto:tismer at stackless.com>
Mission Impossible 5oftware  :     Have a break! Take a ride on Python's
Johannes-Niemeyer-Weg 9a     :    *Starship* http://starship.python.net/
14109 Berlin                 :     PGP key -> http://wwwkeys.pgp.net/
work +49 30 89 09 53 34  home +49 30 802 86 56  mobile +49 173 24 18 776
PGP 0x57F3BF04       9064 F4E1 D754 C2FF 1619  305B C09C 5A3B 57F3 BF04
      whom do you want to sponsor today?   http://www.stackless.com/

Stackless mailing list
Stackless at stackless.com

More information about the Stackless mailing list