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
117b810a
Commit
117b810a
authored
Dec 17, 2019
by
Amir Hosein Kashani
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
3.3 before add sys_call
parent
8f8d871c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
16 deletions
+19
-16
proc.c
proc.c
+16
-15
proc.h
proc.h
+2
-0
trap.c
trap.c
+1
-1
No files found.
proc.c
View file @
117b810a
...
@@ -336,24 +336,25 @@ scheduler(void)
...
@@ -336,24 +336,25 @@ scheduler(void)
for
(
p
=
ptable
.
proc
;
p
<
&
ptable
.
proc
[
NPROC
];
p
++
){
for
(
p
=
ptable
.
proc
;
p
<
&
ptable
.
proc
[
NPROC
];
p
++
){
if
(
p
->
state
!=
RUNNABLE
)
if
(
p
->
state
!=
RUNNABLE
)
continue
;
continue
;
if
(
cpuMode
==
2
){
//choose highest priority
//choose highest priority
struct
proc
*
minimum
=
ptable
.
proc
;
struct
proc
*
minimum
=
ptable
.
proc
;
for
(
p1
=
ptable
.
proc
;
p1
<&
ptable
.
proc
[
NPROC
];
p1
++
){
for
(
p1
=
ptable
.
proc
;
p1
<&
ptable
.
proc
[
NPROC
];
p1
++
){
if
(
p1
->
state
!=
RUNNABLE
){
if
(
p1
->
state
!=
RUNNABLE
){
continue
;
continue
;
}
if
(
minimum
->
calculatedPriority
>
(
p1
->
calculatedPriority
)){
minimum
=
p1
;
}
}
}
if
(
minimum
->
calculatedPriority
>
(
p1
->
calculatedPriority
)){
minimum
->
calculatedPriority
+=
minimum
->
priority
;
minimum
=
p1
;
//for controling larg int and destroy negative priority
if
(
minimum
->
calculatedPriority
<
0
){
minimum
->
calculatedPriority
=
0
;
}
}
p
=
minimum
;
}
}
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
// Switch to chosen process. It is the process's job
// to release ptable.lock and then reacquire it
// to release ptable.lock and then reacquire it
// before jumping back to us.
// before jumping back to us.
...
...
proc.h
View file @
117b810a
...
@@ -12,6 +12,8 @@ struct cpu {
...
@@ -12,6 +12,8 @@ struct cpu {
extern
struct
cpu
cpus
[
NCPU
];
extern
struct
cpu
cpus
[
NCPU
];
extern
int
ncpu
;
extern
int
ncpu
;
extern
int
cpuMode
;
// this field show how schedule system use
//PAGEBREAK: 17
//PAGEBREAK: 17
// Saved registers for kernel context switches.
// Saved registers for kernel context switches.
...
...
trap.c
View file @
117b810a
...
@@ -105,7 +105,7 @@ trap(struct trapframe *tf)
...
@@ -105,7 +105,7 @@ trap(struct trapframe *tf)
currentQuantom
++
;
currentQuantom
++
;
if
(
myproc
()
&&
myproc
()
->
state
==
RUNNING
&&
if
(
myproc
()
&&
myproc
()
->
state
==
RUNNING
&&
tf
->
trapno
==
T_IRQ0
+
IRQ_TIMER
&&
tf
->
trapno
==
T_IRQ0
+
IRQ_TIMER
&&
currentQuantom
%
QUANTUM
==
0
)
(
currentQuantom
%
QUANTUM
==
0
||
cpuMode
!=
1
)
)
yield
();
yield
();
// Check if the process has been killed since we yielded
// Check if the process has been killed since we yielded
...
...
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