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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Krishna Vinnakota
CSEP551
Commits
4f74de0e
Commit
4f74de0e
authored
Sep 27, 2007
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
okay, that was long enough - revert
parent
ce2e7515
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.c
+3
-5
3 additions, 5 deletions
main.c
proc.c
+10
-7
10 additions, 7 deletions
proc.c
proc.h
+1
-4
1 addition, 4 deletions
proc.h
with
14 additions
and
16 deletions
main.c
+
3
−
5
View file @
4f74de0e
...
...
@@ -42,14 +42,12 @@ main(void)
userinit
();
// first user process
// Allocate scheduler stacks and boot the other CPUs.
for
(
i
=
0
;
i
<
ncpu
;
i
++
)
{
for
(
i
=
0
;
i
<
ncpu
;
i
++
)
cpus
[
i
].
stack
=
kalloc
(
KSTACKSIZE
);
*
(
void
**
)(
cpus
[
i
].
stack
+
KSTACKTOP
)
=
0
;
}
bootothers
();
// Switch to our scheduler stack and continue with mpmain.
asm
volatile
(
"movl %0, %%esp"
:
:
"r"
(
cpus
[
bcpu
].
stack
+
KSTACK
TOP
));
asm
volatile
(
"movl %0, %%esp"
:
:
"r"
(
cpus
[
bcpu
].
stack
+
KSTACK
SIZE
));
mpmain
();
}
...
...
@@ -86,7 +84,7 @@ bootothers(void)
continue
;
// Fill in %esp, %eip and start code on cpu.
*
(
void
**
)(
code
-
4
)
=
c
->
stack
+
KSTACK
TOP
;
*
(
void
**
)(
code
-
4
)
=
c
->
stack
+
KSTACK
SIZE
;
*
(
void
**
)(
code
-
8
)
=
mpmain
;
lapic_startap
(
c
->
apicid
,
(
uint
)
code
);
...
...
This diff is collapsed.
Click to expand it.
proc.c
+
10
−
7
View file @
4f74de0e
...
...
@@ -75,7 +75,7 @@ setupsegs(struct proc *p)
c
=
&
cpus
[
cpu
()];
c
->
ts
.
ss0
=
SEG_PROCSTACK
<<
3
;
if
(
p
)
c
->
ts
.
esp0
=
(
uint
)(
p
->
kstack
+
KSTACK
TOP
);
c
->
ts
.
esp0
=
(
uint
)(
p
->
kstack
+
KSTACK
SIZE
);
else
c
->
ts
.
esp0
=
0xffffffff
;
...
...
@@ -118,8 +118,7 @@ copyproc(struct proc *p)
np
->
state
=
UNUSED
;
return
0
;
}
*
(
void
**
)(
np
->
kstack
+
KSTACKTOP
)
=
np
;
np
->
tf
=
(
struct
trapframe
*
)(
np
->
kstack
+
KSTACKTOP
)
-
1
;
np
->
tf
=
(
struct
trapframe
*
)(
np
->
kstack
+
KSTACKSIZE
)
-
1
;
if
(
p
){
// Copy process state from p.
np
->
parent
=
p
;
...
...
@@ -188,10 +187,12 @@ userinit(void)
struct
proc
*
curproc
(
void
)
{
uint
es
p
;
struct
proc
*
p
;
asm
volatile
(
"movl %%esp, %0"
:
"=a"
(
esp
));
return
*
(
struct
proc
**
)((
esp
&
~
(
KSTACKSIZE
-
1
))
+
KSTACKTOP
);
pushcli
();
p
=
cpus
[
cpu
()].
curproc
;
popcli
();
return
p
;
}
//PAGEBREAK: 42
...
...
@@ -222,12 +223,14 @@ scheduler(void)
// Switch to chosen process. It is the process's job
// to release proc_table_lock and then reacquire it
// before jumping back to us.
c
->
curproc
=
p
;
setupsegs
(
p
);
p
->
state
=
RUNNING
;
swtch
(
&
c
->
context
,
&
p
->
context
);
// Process is done running for now.
// It should have changed its p->state before coming back.
c
->
curproc
=
0
;
setupsegs
(
0
);
}
...
...
@@ -236,7 +239,7 @@ scheduler(void)
}
// Enter scheduler. Must already hold proc_table_lock
// and have changed c
p
->state.
// and have changed c
urproc[cpu()]
->state.
void
sched
(
void
)
{
...
...
This diff is collapsed.
Click to expand it.
proc.h
+
1
−
4
View file @
4f74de0e
...
...
@@ -46,10 +46,6 @@ struct proc {
char
name
[
16
];
// Process name (debugging)
};
// The word at kstack + KSTACKTOP is a pointer to the struct proc.
#define KSTACKTOP (KSTACKSIZE-4)
// Process memory is laid out contiguously, low addresses first:
// text
// original data and bss
...
...
@@ -59,6 +55,7 @@ struct proc {
// Per-CPU state
struct
cpu
{
uchar
apicid
;
// Local APIC ID
struct
proc
*
curproc
;
// Process currently running.
struct
context
context
;
// Switch here to enter scheduler
struct
taskstate
ts
;
// Used by x86 to find stack for interrupt
struct
segdesc
gdt
[
NSEGS
];
// x86 global descriptor table
...
...
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
sign in
to comment