apps,nanos-lite,proc,schedule: save trapframe in PCB
This commit is contained in:
parent
5957da34ba
commit
0e62ea0aa9
|
@ -1,12 +1,12 @@
|
|||
#include "common.h"
|
||||
|
||||
_RegSet* schedule(void);
|
||||
_RegSet* schedule(_RegSet *);
|
||||
_RegSet* do_syscall(uintptr_t *);
|
||||
|
||||
static _RegSet* do_event(_Event e, _RegSet* r) {
|
||||
_RegSet *ret = NULL;
|
||||
switch (e.event) {
|
||||
case _EVENT_TRAP: ret = schedule(); break;
|
||||
case _EVENT_TRAP: ret = schedule(r); break;
|
||||
case _EVENT_SYSCALL: ret = do_syscall((uintptr_t *)e.cause); break;
|
||||
default: panic("Unhandled event ID = %d", e.event);
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#define NR_PROC 4
|
||||
|
||||
PCB pcb[NR_PROC];
|
||||
PCB *current;
|
||||
PCB *current = NULL;
|
||||
|
||||
uintptr_t loader(_Protect *as);
|
||||
|
||||
|
@ -19,9 +19,12 @@ void load_first_prog() {
|
|||
pcb[0].tf = _make(stack, (void *)entry, NULL);
|
||||
}
|
||||
|
||||
_RegSet* schedule() {
|
||||
_RegSet* schedule(_RegSet *prev) {
|
||||
Log("schedule");
|
||||
// when current == NULL at the very beginning, it will not cover
|
||||
// any valid data, so it will be safe to write to memory near NULL
|
||||
current->tf = prev;
|
||||
current = &pcb[0];
|
||||
_switch(¤t->as);
|
||||
return pcb[0].tf;
|
||||
return current->tf;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue