Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Armillon Damien
xv6-riscv-tp
Commits
8d2192f4
Commit
8d2192f4
authored
Dec 10, 2020
by
Wilke Pierre
Browse files
TP0
parent
7ead23b3
Changes
5
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
8d2192f4
...
...
@@ -21,3 +21,4 @@ myapi.key
xv6.out*
.vagrant/
submissions/
.vscode/
kernel/console.c
View file @
8d2192f4
...
...
@@ -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'
){
...
...
kernel/proc.c
View file @
8d2192f4
...
...
@@ -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"
);
...
...
kernel/spinlock.c
View file @
8d2192f4
...
...
@@ -28,6 +28,21 @@ initlock(struct spinlock *lk, char *name)
nlock
++
;
}
void
dump_locks
(
void
){
printf_no_lock
(
"LID
\t
LOCKED
\t
CPU
\t
PID
\t
NAME
\t\t
PC
\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
);
}
...
...
kernel/spinlock.h
View file @
8d2192f4
...
...
@@ -14,4 +14,6 @@ struct spinlock {
uint
nts
;
};
void
dump_locks
();
#endif
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment