README revision 12027
112027Sjungma@eit.uni-kl.deThis is a source code distribution for QuickThreads.  QuickThreads is a
212027Sjungma@eit.uni-kl.detoolkit for building threads packages; it is described in detail in the
312027Sjungma@eit.uni-kl.deUniversity of Washington CS&E Technical report #93-05-06, available via
412027Sjungma@eit.uni-kl.deanonymous ftp from `ftp.cs.washington.edu' (128.95.1.4, as of Oct. '94)
512027Sjungma@eit.uni-kl.dein `tr/1993/05/UW-CSE-93-05-06.PS.Z'.
612027Sjungma@eit.uni-kl.de
712027Sjungma@eit.uni-kl.deThis distribution shows basic ideas in QuickThreads and elaborates with
812027Sjungma@eit.uni-kl.deexample implementations for a gaggle of machines.  As of October those
912027Sjungma@eit.uni-kl.demachines included:
1012027Sjungma@eit.uni-kl.de
1112027Sjungma@eit.uni-kl.de	80386 faimly
1212027Sjungma@eit.uni-kl.de	88000 faimily
1312027Sjungma@eit.uni-kl.de	DEC AXP (Alpha) family
1412027Sjungma@eit.uni-kl.de	HP-PA family
1512027Sjungma@eit.uni-kl.de	KSR
1612027Sjungma@eit.uni-kl.de	MIPS family
1712027Sjungma@eit.uni-kl.de	SPARC V8 family
1812027Sjungma@eit.uni-kl.de	VAX family
1912027Sjungma@eit.uni-kl.de
2012027Sjungma@eit.uni-kl.deConfiguration, build, and installation are described in INSTALL.
2112027Sjungma@eit.uni-kl.de
2212027Sjungma@eit.uni-kl.deBe aware: that there is no varargs code for the KSR.
2312027Sjungma@eit.uni-kl.de
2412027Sjungma@eit.uni-kl.deThe HP-PA port was designed to work with both HP workstations
2512027Sjungma@eit.uni-kl.deand Convex SPP computers. It was generously provided by Uwe Reder
2612027Sjungma@eit.uni-kl.de<uereder@cip.informatik.uni-erlangen.de>. It is part of the ELiTE
2712027Sjungma@eit.uni-kl.de(Erlangen Lightweight Thread Environment) project directed by 
2812027Sjungma@eit.uni-kl.deFrank Bellosa <bellosa@informatik.uni-erlangen.de> at the Operating 
2912027Sjungma@eit.uni-kl.deSystems Department of the University of Erlangen (Germany).
3012027Sjungma@eit.uni-kl.de
3112027Sjungma@eit.uni-kl.deOther contributors include: Weihaw Chuang, Richard O'Keefe,
3212027Sjungma@eit.uni-kl.deLaurent Perron, John Polstra, Shinji Suzuki, Assar Westerlund,
3312027Sjungma@eit.uni-kl.dethanks also to Peter Buhr and Dirk Grunwald.
3412027Sjungma@eit.uni-kl.de
3512027Sjungma@eit.uni-kl.de
3612027Sjungma@eit.uni-kl.deHere is a brief summary:
3712027Sjungma@eit.uni-kl.de
3812027Sjungma@eit.uni-kl.deQuickThreads is a toolkit for building threads packages.  It is my hope
3912027Sjungma@eit.uni-kl.dethat you'll find it easier to use QuickThreads normally than to take it
4012027Sjungma@eit.uni-kl.deand modify the raw cswap code to fit your application.  The idea behind
4112027Sjungma@eit.uni-kl.deQuickThreads is that it should make it easy for you to write & retarget
4212027Sjungma@eit.uni-kl.dethreads packages.  If you want the routine `t_create' to create threads
4312027Sjungma@eit.uni-kl.deand `t_block' to suspend threads, you write them using the QuickThreads
4412027Sjungma@eit.uni-kl.de`primitive' operations `QT_SP', `QT_INIT', and `QT_BLOCK', that perform
4512027Sjungma@eit.uni-kl.demachine-dependent initialization and blocking, plus code you supply for
4612027Sjungma@eit.uni-kl.deperforming the portable operatons.  For example, you might write:
4712027Sjungma@eit.uni-kl.de
4812027Sjungma@eit.uni-kl.de	t_create (func, arg)
4912027Sjungma@eit.uni-kl.de	{
5012027Sjungma@eit.uni-kl.de	  stk = malloc (STKSIZE);
5112027Sjungma@eit.uni-kl.de	  stackbase = QT_SP (stk, STKSIZE);
5212027Sjungma@eit.uni-kl.de	  sp = QT_INIT (stakcbase, func, arg);
5312027Sjungma@eit.uni-kl.de	  qput (runq, sp);
5412027Sjungma@eit.uni-kl.de	}
5512027Sjungma@eit.uni-kl.de
5612027Sjungma@eit.uni-kl.deThreads block by doing something like:
5712027Sjungma@eit.uni-kl.de
5812027Sjungma@eit.uni-kl.de	t_block()
5912027Sjungma@eit.uni-kl.de	{
6012027Sjungma@eit.uni-kl.de	  sp_next = qget (runq);
6112027Sjungma@eit.uni-kl.de	  QT_BLOCK (helper, runq, sp_next);
6212027Sjungma@eit.uni-kl.de	  // wake up again here
6312027Sjungma@eit.uni-kl.de	}
6412027Sjungma@eit.uni-kl.de
6512027Sjungma@eit.uni-kl.de	// called by QT_BLOCK after the old thread has blocked,
6612027Sjungma@eit.uni-kl.de	// puts the old thread on the queue `onq'.
6712027Sjungma@eit.uni-kl.de	helper (sp_old, onq)
6812027Sjungma@eit.uni-kl.de	{
6912027Sjungma@eit.uni-kl.de	  qput (onq, sp_old);
7012027Sjungma@eit.uni-kl.de	}
7112027Sjungma@eit.uni-kl.de
7212027Sjungma@eit.uni-kl.de(Of course) it's actually a bit more complex than that, but the general
7312027Sjungma@eit.uni-kl.deidea is that you write portable code to allocate stacks and enqueue and
7412027Sjungma@eit.uni-kl.dedequeue threads.  Than, to get your threads package up and running on a
7512027Sjungma@eit.uni-kl.dedifferent machine, you just reconfigure QuickThreads and recompile, and
7612027Sjungma@eit.uni-kl.dethat's it.
7712027Sjungma@eit.uni-kl.de
7812027Sjungma@eit.uni-kl.deThe QuickThreads `distribution' includes a sample threads package (look
7912027Sjungma@eit.uni-kl.deat stp.{c,h}) that is written in terms of QuickThreads operations.  The
8012027Sjungma@eit.uni-kl.deTR mentioned above explains the simple threads package in detail.
8112027Sjungma@eit.uni-kl.de
8212027Sjungma@eit.uni-kl.de
8312027Sjungma@eit.uni-kl.de
8412027Sjungma@eit.uni-kl.deIf you do use QuickThreads, I'd like to hear both about what worked for
8512027Sjungma@eit.uni-kl.deyou and what didn't work, problems you had, insights gleaned, etc.
8612027Sjungma@eit.uni-kl.de
8712027Sjungma@eit.uni-kl.deLet me know what you think.
8812027Sjungma@eit.uni-kl.de
8912027Sjungma@eit.uni-kl.deDavid Keppel <pardo@cs.washington.edu>
90