StackThreads: An Abstract Machine for Scheduling Fine-Grain Threads on Stock CPUs

We present a software scheduling scheme for fine-grain threads, typical granurality of which is a single procedure invocation. Such fine-grain threads appear in many language implementations such as Multilisp and concurrent object-oriented languages in which an asynchronous procedure/method invocation is a building block of parallel programs. An implementation is described in terms of our abstract machine StackThreads. In the proposed scheme, an asynchronous procedure invocation (a procedure call attached with a thread creation) is performed in less than 10 additional RISC instructions to normal procedure calls in traditional sequential languages such as C, as long as the thread terminates without blocking. StackThreads unifies asynchronous and synchronous procedure calls, deriving a synchronous call by a combination of an asynchronous call + explicit synchronization between the caller and the callee. Therefore, each thread does not have to have its own stack for intrathread procedure calls, simplifying management of activation records. StackThreads serves as a compiler target for general purpose languages such as concurrent object-oriented languages or functional languages on distributed memory multicomputers where the efficiency of intra-node thread management is crucial. We also give benchmark results of our implementation of concurrent object-oriented language ABCL/f, the compiler of which uses StackThreads as the intermediate representation of source programs.