Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
O
OS_XV6
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
9631059
OS_XV6
Commits
3daba6c2
Commit
3daba6c2
authored
Dec 18, 2019
by
Amir Hosein Kashani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3.4 is finnishe and some bugs fixed
parent
aad062e1
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
79 additions
and
6 deletions
+79
-6
defs.h
defs.h
+2
-1
getCountTest.c
getCountTest.c
+6
-3
proc.c
proc.c
+54
-0
syscall.c
syscall.c
+2
-0
syscall.h
syscall.h
+1
-0
sysproc.c
sysproc.c
+10
-0
user.h
user.h
+2
-1
usys.S
usys.S
+2
-1
No files found.
defs.h
View file @
3daba6c2
...
...
@@ -9,7 +9,7 @@ struct spinlock;
struct
sleeplock
;
struct
stat
;
struct
superblock
;
struct
timeVariables
;
// bio.c
void
binit
(
void
);
struct
buf
*
bread
(
uint
,
uint
);
...
...
@@ -121,6 +121,7 @@ int wait(void);
void
wakeup
(
void
*
);
void
yield
(
void
);
void
clockCounter
(
void
);
int
waitForChild
(
struct
timeVariables
*
);
// swtch.S
void
swtch
(
struct
context
**
,
struct
context
*
);
...
...
getCountTest.c
View file @
3daba6c2
#include "types.h"
#include "stat.h"
#include "user.h"
int
main
(
int
argc
,
char
**
argv
)
{
...
...
@@ -13,6 +12,10 @@ main(int argc,char **argv)
//this code for test of 3.3
/*
changePolicy(1);
changePolicy(2);
exit();*/
changePolicy(2);*/
//for 3.4
//struct timeVariables * test;
// waitForChild();
exit
();
}
\ No newline at end of file
proc.c
View file @
3daba6c2
...
...
@@ -88,6 +88,15 @@ allocproc(void)
found:
p
->
state
=
EMBRYO
;
p
->
pid
=
nextpid
++
;
p
->
priority
=
5
;
p
->
calculatedPriority
=
5
;
struct
proc
*
p1
;
for
(
p1
=
ptable
.
proc
;
p1
<
&
ptable
.
proc
[
NPROC
];
p1
++
){
if
(
p1
->
priority
<
p
->
calculatedPriority
){
p
->
calculatedPriority
=
p1
->
priority
;
}
}
release
(
&
ptable
.
lock
);
...
...
@@ -578,3 +587,48 @@ clockCounter(){
}
release
(
&
ptable
.
lock
);
}
int
waitForChild
(
struct
timeVariables
*
input
)
{
struct
proc
*
p
;
int
havekids
,
pid
;
struct
proc
*
curproc
=
myproc
();
acquire
(
&
ptable
.
lock
);
for
(;;){
// Scan through table looking for exited children.
havekids
=
0
;
for
(
p
=
ptable
.
proc
;
p
<
&
ptable
.
proc
[
NPROC
];
p
++
){
if
(
p
->
parent
!=
curproc
)
continue
;
havekids
=
1
;
if
(
p
->
state
==
ZOMBIE
){
// Found one.
pid
=
p
->
pid
;
kfree
(
p
->
kstack
);
p
->
kstack
=
0
;
freevm
(
p
->
pgdir
);
p
->
pid
=
0
;
p
->
parent
=
0
;
p
->
name
[
0
]
=
0
;
p
->
killed
=
0
;
p
->
state
=
UNUSED
;
*
input
=
p
->
timeHandeler
;
release
(
&
ptable
.
lock
);
return
pid
;
}
}
// No point waiting if we don't have any children.
if
(
!
havekids
||
curproc
->
killed
){
release
(
&
ptable
.
lock
);
return
-
1
;
}
// Wait for children to exit. (See wakeup1 call in proc_exit.)
sleep
(
curproc
,
&
ptable
.
lock
);
//DOC: wait-sleep
}
}
\ No newline at end of file
syscall.c
View file @
3daba6c2
...
...
@@ -107,6 +107,7 @@ extern int sys_getChildren(void);
extern
int
sys_getCount
(
void
);
extern
int
sys_changePriority
(
void
);
extern
int
sys_changePolicy
(
void
);
extern
int
sys_waitForChild
(
void
);
static
int
(
*
syscalls
[])(
void
)
=
{
[
SYS_fork
]
sys_fork
,
...
...
@@ -134,6 +135,7 @@ static int (*syscalls[])(void) = {
[
SYS_getCount
]
sys_getCount
,
[
SYS_changePriority
]
sys_changePriority
,
[
SYS_changePolicy
]
sys_changePolicy
,
[
SYS_waitForChild
]
sys_waitForChild
,
};
void
...
...
syscall.h
View file @
3daba6c2
...
...
@@ -24,3 +24,4 @@
#define SYS_getCount 23
#define SYS_changePriority 24
#define SYS_changePolicy 25
#define SYS_waitForChild 26
sysproc.c
View file @
3daba6c2
...
...
@@ -164,6 +164,16 @@ sys_changePolicy(int mode){
return
1
;
}
//3.4
int
sys_waitForChild
(
void
){
struct
timeVariables
*
ct
;
argptr
(
0
,
(
void
*
)
&
ct
,
sizeof
(
*
ct
));
waitForChild
(
ct
);
cprintf
(
"%d"
,
ct
->
readyTime
);
return
1
;
}
...
...
user.h
View file @
3daba6c2
struct
stat
;
struct
rtcdate
;
struct
timeVariables
;
// system calls
int
fork
(
void
);
int
exit
(
void
)
__attribute__
((
noreturn
));
...
...
@@ -27,6 +27,7 @@ int getChildren(int);
int
getCount
(
int
);
int
changePriority
(
int
);
int
changePolicy
(
int
);
int
waitForChild
(
struct
timeVariables
*
);
// ulib.c
int
stat
(
const
char
*
,
struct
stat
*
);
...
...
usys.S
View file @
3daba6c2
...
...
@@ -32,4 +32,5 @@ SYSCALL(uptime)
SYSCALL(getChildren)
SYSCALL(getCount)
SYSCALL(changePriority)
SYSCALL(changePolicy)
\ No newline at end of file
SYSCALL(changePolicy)
SYSCALL(waitForChild)
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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