Skip to content

Commit

Permalink
New scheduler.
Browse files Browse the repository at this point in the history
Removed cli and sti stack in favor of tracking
number of locks held on each CPU and explicit
conditionals in spinlock.c.
  • Loading branch information
rsc committed Jul 16, 2006
1 parent 40a2a08 commit 65bd8e1
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 205 deletions.
2 changes: 1 addition & 1 deletion console.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void
cprintf(char *fmt, ...)
{
int i, state = 0, c;
unsigned int *ap = (unsigned int *) &fmt + 1;
unsigned int *ap = (unsigned int *)(void*)&fmt + 1;

if(use_console_lock)
acquire(&console_lock);
Expand Down
3 changes: 0 additions & 3 deletions defs.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ struct proc;
struct jmpbuf;
void setupsegs(struct proc *);
struct proc * newproc(void);
void swtch(int);
struct spinlock;
void sleep(void *, struct spinlock *);
void wakeup(void *);
Expand All @@ -22,8 +21,6 @@ void proc_exit(void);
int proc_kill(int);
int proc_wait(void);
void yield(void);
void cli(void);
void sti(void);

// swtch.S
struct jmpbuf;
Expand Down
2 changes: 1 addition & 1 deletion dot-bochsrc
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ romimage: file=$BXSHARE/BIOS-bochs-latest, address=0xf0000
# 650Mhz Athlon K-7 with Linux 2.4.4/egcs-2.91.66 2 to 2.5 Mips
# 400Mhz Pentium II with Linux 2.0.36/egcs-1.0.3 1 to 1.8 Mips
#=======================================================================
cpu: count=2, ips=10000000
cpu: count=2, ips=10000000, reset_on_triple_fault=0

#=======================================================================
# MEGS
Expand Down
10 changes: 5 additions & 5 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ extern uint8_t _binary_userfs_start[], _binary_userfs_size[];

extern int use_console_lock;

struct spinlock sillylock; // hold this to keep interrupts disabled

int
main()
{
struct proc *p;

if (acpu) {
cpus[cpu()].clis = 1;
cprintf("an application processor\n");
idtinit(); // CPU's idt
lapic_init(cpu());
lapic_timerinit();
lapic_enableintr();
sti();
scheduler();
}
acpu = 1;
Expand All @@ -40,10 +40,9 @@ main()

mp_init(); // collect info about this machine

acquire(&sillylock);
use_console_lock = 1;

cpus[cpu()].clis = 1; // cpu starts as if we had called cli()

lapic_init(mp_bcpu());

cprintf("\nxV6\n\n");
Expand All @@ -56,7 +55,7 @@ main()
// create fake process zero
p = &proc[0];
memset(p, 0, sizeof *p);
p->state = WAITING;
p->state = SLEEPING;
p->sz = 4 * PAGE;
p->mem = kalloc(p->sz);
memset(p->mem, 0, p->sz);
Expand Down Expand Up @@ -88,6 +87,7 @@ main()
//load_icode(p, _binary_userfs_start, (unsigned) _binary_userfs_size);
p->state = RUNNABLE;
cprintf("loaded userfs\n");
release(&sillylock);

scheduler();

Expand Down
Loading

0 comments on commit 65bd8e1

Please sign in to comment.