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
8f8d871c
Commit
8f8d871c
authored
Dec 16, 2019
by
Amir Hosein Kashani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
before testing 3.2
parent
616316e1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
39 additions
and
1 deletion
+39
-1
proc.c
proc.c
+18
-0
proc.h
proc.h
+1
-0
syscall.c
syscall.c
+3
-1
syscall.h
syscall.h
+1
-0
sysproc.c
sysproc.c
+14
-0
user.h
user.h
+1
-0
usys.S
usys.S
+1
-0
No files found.
proc.c
View file @
8f8d871c
...
...
@@ -324,6 +324,7 @@ scheduler(void)
{
struct
proc
*
p
;
struct
cpu
*
c
=
mycpu
();
struct
proc
*
p1
;
c
->
proc
=
0
;
for
(;;){
...
...
@@ -336,6 +337,23 @@ scheduler(void)
if
(
p
->
state
!=
RUNNABLE
)
continue
;
//choose highest priority
struct
proc
*
minimum
=
ptable
.
proc
;
for
(
p1
=
ptable
.
proc
;
p1
<&
ptable
.
proc
[
NPROC
];
p1
++
){
if
(
p1
->
state
!=
RUNNABLE
){
continue
;
}
if
(
minimum
->
calculatedPriority
>
(
p1
->
calculatedPriority
)){
minimum
=
p1
;
}
}
minimum
->
calculatedPriority
+=
minimum
->
priority
;
//for controling larg int and destroy negative priority
if
(
minimum
->
calculatedPriority
<
0
){
minimum
->
calculatedPriority
=
0
;
}
p
=
minimum
;
// Switch to chosen process. It is the process's job
// to release ptable.lock and then reacquire it
// before jumping back to us.
...
...
proc.h
View file @
8f8d871c
...
...
@@ -39,6 +39,7 @@ struct proc {
int
usagepointer
;
int
usage
[
100
];
int
priority
;
int
calculatedPriority
;
uint
sz
;
// Size of process memory (bytes)
pde_t
*
pgdir
;
// Page table
char
*
kstack
;
// Bottom of kernel stack for this process
...
...
syscall.c
View file @
8f8d871c
...
...
@@ -105,6 +105,7 @@ extern int sys_write(void);
extern
int
sys_uptime
(
void
);
extern
int
sys_getChildren
(
void
);
extern
int
sys_getCount
(
void
);
extern
int
sys_changePriority
(
void
);
static
int
(
*
syscalls
[])(
void
)
=
{
[
SYS_fork
]
sys_fork
,
...
...
@@ -129,7 +130,8 @@ static int (*syscalls[])(void) = {
[
SYS_mkdir
]
sys_mkdir
,
[
SYS_close
]
sys_close
,
[
SYS_getChildren
]
sys_getChildren
,
[
SYS_getCount
]
sys_getCount
[
SYS_getCount
]
sys_getCount
,
[
SYS_changePriority
]
sys_changePriority
};
void
...
...
syscall.h
View file @
8f8d871c
...
...
@@ -22,3 +22,4 @@
#define SYS_close 21
#define SYS_getChildren 22
#define SYS_getCount 23
#define SYS_changePriority 24
sysproc.c
View file @
8f8d871c
...
...
@@ -138,6 +138,20 @@ sys_getCount(int find){
return
counter
;
}
//3.2
int
changePriority
(
int
newPriority
){
argint
(
0
,
&
newPriority
);
if
(
newPriority
>
5
||
newPriority
<
0
){
return
-
1
;
}
myproc
()
->
calculatedPriority
=
newPriority
;
myproc
()
->
priority
=
newPriority
;
return
5
;
}
...
...
user.h
View file @
8f8d871c
...
...
@@ -25,6 +25,7 @@ int sleep(int);
int
uptime
(
void
);
int
getChildren
(
int
);
int
getCount
(
int
);
int
changePriority
(
int
);
// ulib.c
int
stat
(
const
char
*
,
struct
stat
*
);
...
...
usys.S
View file @
8f8d871c
...
...
@@ -31,3 +31,4 @@ SYSCALL(sleep)
SYSCALL(uptime)
SYSCALL(getChildren)
SYSCALL(getCount)
SYSCALL(changePriority)
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