push_off() and pop_off() in myproc()
This commit is contained in:
parent
3113643768
commit
5eb1cb4972
|
@ -17,7 +17,7 @@
|
||||||
|
|
||||||
static void consputc(int);
|
static void consputc(int);
|
||||||
|
|
||||||
static int panicked = 0;
|
static volatile int panicked = 0;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
struct spinlock lock;
|
struct spinlock lock;
|
||||||
|
@ -120,6 +120,7 @@ printf(char *fmt, ...)
|
||||||
void
|
void
|
||||||
panic(char *s)
|
panic(char *s)
|
||||||
{
|
{
|
||||||
|
cons.locking = 0;
|
||||||
printf("panic: ");
|
printf("panic: ");
|
||||||
printf(s);
|
printf(s);
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
10
proc.c
10
proc.c
|
@ -11,7 +11,6 @@ struct {
|
||||||
struct proc proc[NPROC];
|
struct proc proc[NPROC];
|
||||||
} ptable;
|
} ptable;
|
||||||
|
|
||||||
// XXX riscv move somewhere else
|
|
||||||
struct cpu cpus[NCPU];
|
struct cpu cpus[NCPU];
|
||||||
|
|
||||||
struct proc *initproc;
|
struct proc *initproc;
|
||||||
|
@ -54,10 +53,10 @@ mycpu(void) {
|
||||||
// Return the current struct proc *.
|
// Return the current struct proc *.
|
||||||
struct proc*
|
struct proc*
|
||||||
myproc(void) {
|
myproc(void) {
|
||||||
// XXX push intr off
|
push_off();
|
||||||
struct cpu *c = mycpu();
|
struct cpu *c = mycpu();
|
||||||
struct proc *p = c->proc;
|
struct proc *p = c->proc;
|
||||||
// XXX pop intr
|
pop_off();
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,8 +402,13 @@ sched(void)
|
||||||
|
|
||||||
if(!holding(&ptable.lock))
|
if(!holding(&ptable.lock))
|
||||||
panic("sched ptable.lock");
|
panic("sched ptable.lock");
|
||||||
|
if(mycpu()->noff != 1)
|
||||||
|
panic("sched locks");
|
||||||
if(p->state == RUNNING)
|
if(p->state == RUNNING)
|
||||||
panic("sched running");
|
panic("sched running");
|
||||||
|
if(intr_get())
|
||||||
|
panic("sched interruptible");
|
||||||
|
|
||||||
intena = mycpu()->intena;
|
intena = mycpu()->intena;
|
||||||
swtch(&p->context, &mycpu()->scheduler);
|
swtch(&p->context, &mycpu()->scheduler);
|
||||||
mycpu()->intena = intena;
|
mycpu()->intena = intena;
|
||||||
|
|
Loading…
Reference in a new issue