Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
b74f4b57
Commit
b74f4b57
authored
18 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
Keep interrupts disabled during startup.
parent
ef2bd07a
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.c
+27
-16
27 additions, 16 deletions
main.c
mp.c
+3
-1
3 additions, 1 deletion
mp.c
spinlock.c
+2
-2
2 additions, 2 deletions
spinlock.c
with
32 additions
and
19 deletions
main.c
+
27
−
16
View file @
b74f4b57
...
...
@@ -11,36 +11,30 @@
#include
"spinlock.h"
extern
char
edata
[],
end
[];
extern
int
acpu
;
extern
uint8_t
_binary_user1_start
[],
_binary_user1_size
[];
extern
uint8_t
_binary_usertests_start
[],
_binary_usertests_size
[];
extern
uint8_t
_binary_userfs_start
[],
_binary_userfs_size
[];
extern
int
use_console_lock
;
struct
spinlock
sillylock
;
// hold this to keep interrupts disabled
// CPU 0 starts running C code here.
int
main
()
{
int
i
;
struct
proc
*
p
;
if
(
acpu
)
{
cprintf
(
"an application processor
\n
"
);
idtinit
();
// CPU's idt
lapic_init
(
cpu
());
lapic_timerinit
();
lapic_enableintr
();
scheduler
();
}
acpu
=
1
;
// clear BSS
memset
(
edata
,
0
,
end
-
edata
);
// Make sure interrupts stay disabled on all processors
// until each signals it is ready, by pretending to hold
// an extra lock.
for
(
i
=
0
;
i
<
NCPU
;
i
++
)
cpus
[
i
].
nlock
++
;
mp_init
();
// collect info about this machine
acquire
(
&
sillylock
);
use_console_lock
=
1
;
lapic_init
(
mp_bcpu
());
...
...
@@ -78,7 +72,8 @@ main()
// init disk device
//ide_init();
// become interruptable
// Enable interrupts on this processor.
cpus
[
cpu
()].
nlock
--
;
sti
();
p
=
copyproc
(
&
proc
[
0
]);
...
...
@@ -87,13 +82,29 @@ main()
//load_icode(p, _binary_userfs_start, (unsigned) _binary_userfs_size);
p
->
state
=
RUNNABLE
;
cprintf
(
"loaded userfs
\n
"
);
release
(
&
sillylock
);
scheduler
();
return
0
;
}
// Additional processors start here.
int
mpmain
(
void
)
{
cprintf
(
"an application processor
\n
"
);
idtinit
();
// CPU's idt
lapic_init
(
cpu
());
lapic_timerinit
();
lapic_enableintr
();
// Enable interrupts on this processor.
cpus
[
cpu
()].
nlock
--
;
sti
();
scheduler
();
}
void
load_icode
(
struct
proc
*
p
,
uint8_t
*
binary
,
unsigned
size
)
{
...
...
This diff is collapsed.
Click to expand it.
mp.c
+
3
−
1
View file @
b74f4b57
...
...
@@ -191,6 +191,8 @@ mp_bcpu(void)
return
bcpu
-
cpus
;
}
extern
void
mpmain
(
void
);
void
mp_startthem
()
{
...
...
@@ -205,7 +207,7 @@ mp_startthem()
if
(
c
==
cpu
())
continue
;
cprintf
(
"starting processor %d
\n
"
,
c
);
*
(
unsigned
*
)(
APBOOTCODE
-
4
)
=
(
unsigned
)
(
cpus
[
c
].
mpstack
)
+
MPSTACK
;
// tell it what to use for %esp
*
(
unsigned
*
)(
APBOOTCODE
-
8
)
=
(
unsigned
)
&
main
;
// tell it where to jump to
*
(
unsigned
*
)(
APBOOTCODE
-
8
)
=
(
unsigned
)
mp
main
;
// tell it where to jump to
lapic_startap
(
cpus
[
c
].
apicid
,
(
uint32_t
)
APBOOTCODE
);
}
}
This diff is collapsed.
Click to expand it.
spinlock.c
+
2
−
2
View file @
b74f4b57
...
...
@@ -10,7 +10,7 @@
// because cprintf uses them itself.
#define cprintf dont_use_cprintf
extern
int
bootstrap
;
extern
int
use_console_lock
;
int
getcallerpc
(
void
*
v
)
...
...
@@ -34,7 +34,7 @@ release(struct spinlock * lock)
{
cpuid
(
0
,
0
,
0
,
0
,
0
);
// memory barrier
lock
->
locked
=
0
;
if
(
--
cpus
[
cpu
()].
nlock
==
0
&&
!
bootstrap
)
if
(
--
cpus
[
cpu
()].
nlock
==
0
)
sti
();
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment