Commit 8d2192f4 authored by Wilke Pierre's avatar Wilke Pierre

TP0

parent 7ead23b3
......@@ -21,3 +21,4 @@ myapi.key
xv6.out*
.vagrant/
submissions/
.vscode/
......@@ -168,6 +168,9 @@ consoleintr(int c)
case C('Q'): // Print priority list
priodump();
break;
case C('L'):
dump_locks();
break;
case C('U'): // Kill line.
while(cons->e != cons->w &&
cons->buf[(cons->e-1) % INPUT_BUF] != '\n'){
......
......@@ -534,7 +534,7 @@ scheduler(void)
// again to avoid a race between interrupt and WFI.
c->intena = 0;
release(&p->lock);
// release(&p->lock);
}
if(found == 0){
asm volatile("wfi");
......
......@@ -28,6 +28,21 @@ initlock(struct spinlock *lk, char *name)
nlock++;
}
void dump_locks(void){
printf_no_lock("LID\tLOCKED\tCPU\tPID\tNAME\t\tPC\n");
for(int i = 0; i < nlock; i++){
if(locks[i]->locked)
printf_no_lock("%d\t%d\t%d\t%d\t%s\t\t%p\n",
i,
locks[i]->locked,
locks[i]->cpu - cpus,
locks[i]->pid,
locks[i]->name,
locks[i]->pc
);
}
}
#define MAXTRIES 100000
// Acquire the lock.
......@@ -76,7 +91,7 @@ acquire(struct spinlock *lk)
}
__sync_fetch_and_add(&lk->nts, 1);
}
if(nbtries > MAXTRIES){
if(warned){
printf_no_lock("CPU %d: Finally acquired %s (%p) after %d tries\n", cpuid(), lk->name, lk, nbtries);
}
......
......@@ -14,4 +14,6 @@ struct spinlock {
uint nts;
};
void dump_locks();
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment