Skip to content
Snippets Groups Projects
Commit e076b1cc authored by Wilke Pierre's avatar Wilke Pierre
Browse files

TP1 init

parent 7ead23b3
No related branches found
No related tags found
No related merge requests found
......@@ -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'){
......
......@@ -26,8 +26,6 @@ static void wakeup1(struct proc *chan);
extern char trampoline[]; // trampoline.S
/* Solution insert et remove
// Needs lock on p and prio_lock[p->priority]
void insert_into_prio_queue(struct proc* p){
struct list_proc* new = bd_malloc(sizeof(struct list_proc));
......@@ -67,7 +65,6 @@ void remove_from_prio_queue(struct proc* p){
prio[p->priority] = head;
}
*/
void
procinit(void)
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment