int holding(struct spinlock*);
void initlock(struct spinlock*, char*);
void release(struct spinlock*);
-void splhi();
-void spllo();
+void pushcli();
+void popcli();
// string.c
int memcmp(const void*, const void*, uint);
// clear BSS
memset(edata, 0, end - edata);
- // splhi() every processor during bootstrap.
+ // pushcli() every processor during bootstrap.
for(i=0; i<NCPU; i++)
- cpus[i].nsplhi = 1; // no interrupts during bootstrap
+ cpus[i].ncli = 1; // no interrupts during bootstrap
mp_init(); // collect info about this machine
bcpu = mp_bcpu();
asm volatile("movl %0, %%ss" :: "r" (SEG_CPUSTACK << 3));
cpuid(0, 0, 0, 0, 0); // memory barrier
cpus[cpu()].booted = 1;
- spllo();
+ popcli();
scheduler();
}
{
struct cpu *c;
- splhi();
+ pushcli();
c = &cpus[cpu()];
c->ts.ss0 = SEG_PROCSTACK << 3;
if(p)
lgdt(c->gdt, sizeof(c->gdt));
ltr(SEG_TSS << 3);
- spllo();
+ popcli();
}
// Create a new process copying p as the parent.
{
struct proc *p;
- splhi();
+ pushcli();
p = cpus[cpu()].curproc;
- spllo();
+ popcli();
return p;
}
panic("sched running");
if(!holding(&proc_table_lock))
panic("sched proc_table_lock");
- if(cpus[cpu()].nsplhi != 1)
+ if(cpus[cpu()].ncli != 1)
panic("sched locks");
swtch(&cp->context, &cpus[cpu()].context);
struct segdesc gdt[NSEGS]; // x86 global descriptor table
char *stack;
volatile int booted; // Has the CPU started?
- int nsplhi; // Depth of splhi nesting.
+ int ncli; // Depth of pushcli nesting.
};
extern struct cpu cpus[NCPU];
void
acquire(struct spinlock *lock)
{
- splhi();
+ pushcli();
if(holding(lock))
panic("acquire");
cpuid(0, 0, 0, 0, 0); // memory barrier (see Ch 7, IA-32 manual vol 3)
lock->locked = 0;
- spllo();
+ popcli();
}
// Record the current call stack in pcs[] by following the %ebp chain.
// Better names? Better functions?
void
-splhi(void)
+pushcli(void)
{
cli();
- cpus[cpu()].nsplhi++;
+ cpus[cpu()].ncli++;
}
void
-spllo(void)
+popcli(void)
{
if(read_eflags()&FL_IF)
- panic("spllo - interruptible");
- if(--cpus[cpu()].nsplhi < 0)
- panic("spllo");
- if(cpus[cpu()].nsplhi == 0)
+ panic("popcli - interruptible");
+ if(--cpus[cpu()].ncli < 0)
+ panic("popcli");
+ if(cpus[cpu()].ncli == 0)
sti();
}
}
// No interrupts during interrupt handling.
- splhi();
+ pushcli();
switch(tf->trapno){
case IRQ_OFFSET + IRQ_TIMER:
cp->killed = 1;
}
- spllo();
+ popcli();
// Force process exit if it has been killed and is in user space.
// (If it is still executing in the kernel, let it keep running