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

TP0

parent 7ead23b3
...@@ -21,3 +21,4 @@ myapi.key ...@@ -21,3 +21,4 @@ myapi.key
xv6.out* xv6.out*
.vagrant/ .vagrant/
submissions/ submissions/
.vscode/
...@@ -168,6 +168,9 @@ consoleintr(int c) ...@@ -168,6 +168,9 @@ consoleintr(int c)
case C('Q'): // Print priority list case C('Q'): // Print priority list
priodump(); priodump();
break; break;
case C('L'):
dump_locks();
break;
case C('U'): // Kill line. case C('U'): // Kill line.
while(cons->e != cons->w && while(cons->e != cons->w &&
cons->buf[(cons->e-1) % INPUT_BUF] != '\n'){ cons->buf[(cons->e-1) % INPUT_BUF] != '\n'){
......
...@@ -534,7 +534,7 @@ scheduler(void) ...@@ -534,7 +534,7 @@ scheduler(void)
// again to avoid a race between interrupt and WFI. // again to avoid a race between interrupt and WFI.
c->intena = 0; c->intena = 0;
release(&p->lock); // release(&p->lock);
} }
if(found == 0){ if(found == 0){
asm volatile("wfi"); asm volatile("wfi");
......
...@@ -28,6 +28,21 @@ initlock(struct spinlock *lk, char *name) ...@@ -28,6 +28,21 @@ initlock(struct spinlock *lk, char *name)
nlock++; 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 #define MAXTRIES 100000
// Acquire the lock. // Acquire the lock.
...@@ -76,7 +91,7 @@ acquire(struct spinlock *lk) ...@@ -76,7 +91,7 @@ acquire(struct spinlock *lk)
} }
__sync_fetch_and_add(&lk->nts, 1); __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); printf_no_lock("CPU %d: Finally acquired %s (%p) after %d tries\n", cpuid(), lk->name, lk, nbtries);
} }
......
...@@ -14,4 +14,6 @@ struct spinlock { ...@@ -14,4 +14,6 @@ struct spinlock {
uint nts; uint nts;
}; };
void dump_locks();
#endif #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