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
ad0e0b5f
Commit
ad0e0b5f
authored
Dec 18, 2019
by
Amir Hosein Kashani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add struct for timing
parent
c9a111a5
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
4 deletions
+43
-4
getCountTest.c
getCountTest.c
+5
-1
proc.c
proc.c
+8
-0
proc.h
proc.h
+10
-0
syscall.c
syscall.c
+3
-1
syscall.h
syscall.h
+1
-0
sysproc.c
sysproc.c
+13
-1
trap.c
trap.c
+1
-1
user.h
user.h
+1
-0
usys.S
usys.S
+1
-0
No files found.
getCountTest.c
View file @
ad0e0b5f
...
...
@@ -10,5 +10,9 @@ main(int argc,char **argv)
getChildren
(
a
);
int
result
=
getCount
(
22
);
printf
(
1
,
"--- %d ---"
,
result
);
exit
();
//this code for test of 3.3
/*
changePolicy(1);
changePolicy(2);
exit();*/
}
\ No newline at end of file
proc.c
View file @
ad0e0b5f
...
...
@@ -112,6 +112,14 @@ found:
memset
(
p
->
context
,
0
,
sizeof
*
p
->
context
);
p
->
context
->
eip
=
(
uint
)
forkret
;
//kashaia
p
->
timeHandeler
.
creationTime
=
ticks
;
p
->
timeHandeler
.
runningTime
=
0
;
p
->
timeHandeler
.
sleepingTime
=
0
;
p
->
timeHandeler
.
readyTime
=
0
;
return
p
;
}
...
...
proc.h
View file @
ad0e0b5f
...
...
@@ -34,10 +34,20 @@ struct context {
uint
eip
;
};
struct
timeVariables
{
//this struct for 3.4
int
creationTime
;
int
terminationTime
;
int
sleepingTime
;
int
readyTime
;
int
runningTime
;
};
enum
procstate
{
UNUSED
,
EMBRYO
,
SLEEPING
,
RUNNABLE
,
RUNNING
,
ZOMBIE
};
// Per-process state
struct
proc
{
struct
timeVariables
timeHandeler
;
int
usagepointer
;
int
usage
[
100
];
int
priority
;
...
...
syscall.c
View file @
ad0e0b5f
...
...
@@ -106,6 +106,7 @@ extern int sys_uptime(void);
extern
int
sys_getChildren
(
void
);
extern
int
sys_getCount
(
void
);
extern
int
sys_changePriority
(
void
);
extern
int
sys_changePolicy
(
void
);
static
int
(
*
syscalls
[])(
void
)
=
{
[
SYS_fork
]
sys_fork
,
...
...
@@ -131,7 +132,8 @@ static int (*syscalls[])(void) = {
[
SYS_close
]
sys_close
,
[
SYS_getChildren
]
sys_getChildren
,
[
SYS_getCount
]
sys_getCount
,
[
SYS_changePriority
]
sys_changePriority
[
SYS_changePriority
]
sys_changePriority
,
[
SYS_changePolicy
]
sys_changePolicy
,
};
void
...
...
syscall.h
View file @
ad0e0b5f
...
...
@@ -23,3 +23,4 @@
#define SYS_getChildren 22
#define SYS_getCount 23
#define SYS_changePriority 24
#define SYS_changePolicy 25
sysproc.c
View file @
ad0e0b5f
...
...
@@ -8,7 +8,7 @@
#include "proc.h"
int
table
[
1200
][
256
]
=
{
0
};
extern
int
cpuMode
;
int
sys_getpid
(
void
)
{
...
...
@@ -152,6 +152,18 @@ sys_changePriority(int newPriority){
return
5
;
}
//3.3
int
sys_changePolicy
(
int
mode
){
argint
(
0
,
&
mode
);
if
(
mode
>
2
||
mode
<
0
){
return
-
1
;
}
cprintf
(
"%d"
,
cpuMode
);
cpuMode
=
mode
;
return
1
;
}
...
...
trap.c
View file @
ad0e0b5f
...
...
@@ -37,6 +37,7 @@ idtinit(void)
void
trap
(
struct
trapframe
*
tf
)
{
if
(
tf
->
trapno
==
T_SYSCALL
){
if
(
myproc
()
->
killed
)
exit
();
...
...
@@ -46,7 +47,6 @@ trap(struct trapframe *tf)
exit
();
return
;
}
switch
(
tf
->
trapno
){
case
T_IRQ0
+
IRQ_TIMER
:
if
(
cpuid
()
==
0
){
...
...
user.h
View file @
ad0e0b5f
...
...
@@ -26,6 +26,7 @@ int uptime(void);
int
getChildren
(
int
);
int
getCount
(
int
);
int
changePriority
(
int
);
int
changePolicy
(
int
);
// ulib.c
int
stat
(
const
char
*
,
struct
stat
*
);
...
...
usys.S
View file @
ad0e0b5f
...
...
@@ -32,3 +32,4 @@ SYSCALL(uptime)
SYSCALL(getChildren)
SYSCALL(getCount)
SYSCALL(changePriority)
SYSCALL(changePolicy)
\ 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