Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CSEP551
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
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
21573833
Commit
21573833
authored
15 years ago
by
rsc
Browse files
Options
Downloads
Patches
Plain Diff
move fork into proc.c
parent
dae9b0d4
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
defs.h
+4
-3
4 additions, 3 deletions
defs.h
proc.c
+20
-14
20 additions, 14 deletions
proc.c
sysproc.c
+1
-11
1 addition, 11 deletions
sysproc.c
with
25 additions
and
28 deletions
defs.h
+
4
−
3
View file @
21573833
...
...
@@ -94,6 +94,7 @@ int pipewrite(struct pipe*, char*, int);
// proc.c
struct
proc
*
copyproc
(
struct
proc
*
);
void
exit
(
void
);
int
fork
(
void
);
int
growproc
(
int
);
int
kill
(
int
);
void
pinit
(
void
);
...
...
@@ -146,9 +147,9 @@ void tvinit(void);
extern
struct
spinlock
tickslock
;
// uart.c
void
uartinit
(
void
);
void
uartintr
(
void
);
void
uartputc
(
int
);
void
uartinit
(
void
);
void
uartintr
(
void
);
void
uartputc
(
int
);
// number of elements in fixed-size array
...
...
This diff is collapsed.
Click to expand it.
proc.c
+
20
−
14
View file @
21573833
...
...
@@ -130,34 +130,40 @@ usegment(void)
// Create a new process copying p as the parent.
// Sets up stack to return as if from system call.
// Caller must set state of returned proc to RUNNABLE.
struct
proc
*
copyproc
(
struct
proc
*
p
)
int
fork
(
void
)
{
int
i
;
int
i
,
pid
;
struct
proc
*
np
;
// Allocate process.
if
((
np
=
allocproc
())
==
0
)
return
0
;
return
-
1
;
// Copy process state from p.
np
->
sz
=
p
->
sz
;
np
->
sz
=
c
p
->
sz
;
if
((
np
->
mem
=
kalloc
(
np
->
sz
))
==
0
){
kfree
(
np
->
kstack
,
KSTACKSIZE
);
np
->
kstack
=
0
;
np
->
state
=
UNUSED
;
return
0
;
return
-
1
;
}
memmove
(
np
->
mem
,
p
->
mem
,
np
->
sz
);
np
->
parent
=
p
;
*
np
->
tf
=
*
p
->
tf
;
memmove
(
np
->
mem
,
c
p
->
mem
,
np
->
sz
);
np
->
parent
=
c
p
;
*
np
->
tf
=
*
c
p
->
tf
;
for
(
i
=
0
;
i
<
NOFILE
;
i
++
)
if
(
p
->
ofile
[
i
])
np
->
ofile
[
i
]
=
filedup
(
p
->
ofile
[
i
]);
np
->
cwd
=
idup
(
p
->
cwd
);
// Clear %eax so that fork returns 0 in the child.
np
->
tf
->
eax
=
0
;
return
np
;
for
(
i
=
0
;
i
<
NOFILE
;
i
++
)
if
(
cp
->
ofile
[
i
])
np
->
ofile
[
i
]
=
filedup
(
cp
->
ofile
[
i
]);
np
->
cwd
=
idup
(
cp
->
cwd
);
pid
=
np
->
pid
;
np
->
state
=
RUNNABLE
;
return
pid
;
}
// Set up first user process.
...
...
This diff is collapsed.
Click to expand it.
sysproc.c
+
1
−
11
View file @
21573833
...
...
@@ -8,17 +8,7 @@
int
sys_fork
(
void
)
{
int
pid
;
struct
proc
*
np
;
if
((
np
=
copyproc
(
cp
))
==
0
)
return
-
1
;
pid
=
np
->
pid
;
// Clear %eax so that fork returns 0 in the child.
np
->
tf
->
eax
=
0
;
np
->
state
=
RUNNABLE
;
return
pid
;
return
fork
();
}
int
...
...
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