What kinds of things would you want in the GNU OS?

Peter da Silva peter at ficc.uu.net
Thu Jun 1 05:30:11 AEST 1989


In article <16603 at rpp386.Dallas.TX.US>, jfh at rpp386.Dallas.TX.US (John F. Haugh II) writes:
> In article <4347 at ficc.uu.net> peter at ficc.uu.net (Peter da Silva) writes:
> >An efficient version of threads would not even duplicate the stack area...


> As you unwind stack frames in either thread, you would reach a point
> where you start trashing the stack frames of the either thread.

This assumes you can unwind the stack. You're assuming that the thread()
call looks like fork(). That's not efficient. You need something like:

pid = thread(initial_PC, final_PC, initial_stack_size, maximum_stack_size, priority);

Used like so:

	void do_raytrace();
	void cleanup();
	int trace_pid;

	trace_pid = thread(do_raytrace, cleanup, 256, 1024, 5);

This creates a new stack for the thread (256 bytes if it's growable, 1024
bytes otherwise), pushes the address of 'cleanup' on it, and jumps to the
start routine: do_raytrace(). Cleanup looks like this:

	cleanup()
	{
		thread_exit();
	}

This avoids duplicating (or potentially duplicating) a large amount of data,
and avoids having to swap MMU contexts for the new stack when you enter the
thread. The entire MMU context of the parent and child threads can be the
same.
-- 
Peter da Silva, Xenix Support, Ferranti International Controls Corporation.

Business: uunet.uu.net!ficc!peter, peter at ficc.uu.net, +1 713 274 5180.
Personal: ...!texbell!sugar!peter, peter at sugar.hackercorp.com.



More information about the Comp.unix.wizards mailing list