xv6 is a modern re-implementation of Sixth Edition Unix in ANSI C for multiprocessor x86/x86_64 systems.
Find a file
rsc 5ce9751cab Changes to allow use of native x86 ELF compilers, which on my
Linux 2.4 box using gcc 3.4.6 don't seem to follow the same
conventions as the i386-jos-elf-gcc compilers.
Can run make 'TOOLPREFIX=' or edit the Makefile.

curproc[cpu()] can now be NULL, indicating that no proc is running.
This seemed safer to me than having curproc[0] and curproc[1]
both pointing at proc[0] potentially.

The old implementation of swtch depended on the stack frame layout
used inside swtch being okay to return from on the other stack
(exactly the V6 you are not expected to understand this).
It also could be called in two contexts: at boot time, to schedule
the very first process, and later, on behalf of a process, to sleep
or schedule some other process.

I split this into two functions: scheduler and swtch.

The scheduler is now a separate never-returning function, invoked
by each cpu once set up.  The scheduler looks like:

	scheduler() {
		setjmp(cpu.context);

		pick proc to schedule
		blah blah blah

		longjmp(proc.context)
	}

The new swtch is intended to be called only when curproc[cpu()] is not NULL,
that is, only on behalf of a user proc.  It does:

	swtch() {
		if(setjmp(proc.context) == 0)
			longjmp(cpu.context)
	}

to save the current proc context and then jump over to the scheduler,
running on the cpu stack.

Similarly the system call stubs are now in assembly in usys.S to avoid
needing to know the details of stack frame layout used by the compiler.

Also various changes in the debugging prints.
2006-07-11 01:07:40 +00:00
.cvsignore Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
asm.h oops 2006-06-22 15:28:09 +00:00
bootasm.S checkpoint. booting second processor. stack is messed up, but thanks to cliff 2006-06-22 01:28:57 +00:00
bootmain.c import 2006-06-12 15:22:12 +00:00
bootother.S stick mpstack in cpu structure 2006-06-26 16:40:43 +00:00
console.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
defs.h Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
dot-bochsrc Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
elf.h import 2006-06-12 15:22:12 +00:00
fd.c swtch saves callee-saved registers 2006-07-01 21:26:01 +00:00
fd.h file descriptors 2006-06-27 14:35:53 +00:00
ide.c queue with disk requests 2006-07-10 19:06:48 +00:00
kalloc.c swtch saves callee-saved registers 2006-07-01 21:26:01 +00:00
main.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
Makefile Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
memlayout.h boot more than two CPUs, each on own initial stack 2006-06-24 22:47:06 +00:00
mmu.h import 2006-06-12 15:22:12 +00:00
mp.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
mp.h timer interrupts 2006-06-28 16:35:03 +00:00
Notes Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
param.h queue with disk requests 2006-07-10 19:06:48 +00:00
picirq.c timer interrupts 2006-07-05 20:00:14 +00:00
pipe.c swtch saves callee-saved registers 2006-07-01 21:26:01 +00:00
proc.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
proc.h Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
sign.pl import 2006-06-12 15:22:12 +00:00
spinlock.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
string.c timer interrupts 2006-07-05 20:00:14 +00:00
swtch.S Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
syscall.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
syscall.h disable all interrupts when acquiring lock 2006-07-06 21:47:22 +00:00
trap.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
trapasm.S Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
traps.h timer interrupts 2006-06-28 16:35:03 +00:00
types.h import 2006-06-12 15:22:12 +00:00
ulib.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
user1.c file descriptors 2006-06-27 14:35:53 +00:00
userfs.c Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
usertests.c swtch saves callee-saved registers 2006-07-01 21:26:01 +00:00
usys.S Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00
vectors.pl fix some trap bugs 2006-06-13 22:08:20 +00:00
x86.h Changes to allow use of native x86 ELF compilers, which on my 2006-07-11 01:07:40 +00:00