Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp30023-practical-1
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
yufanzhang
comp30023-practical-1
Commits
f04c8f52
Commit
f04c8f52
authored
2 years ago
by
Syufan
Browse files
Options
Downloads
Patches
Plain Diff
fix fit sjf
parent
bd16168a
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
allocate.c
+10
-6
10 additions, 6 deletions
allocate.c
with
10 additions
and
6 deletions
allocate.c
+
10
−
6
View file @
f04c8f52
...
...
@@ -435,10 +435,11 @@ int main(int argc, char *argv[]) {
strcpy
(
processing
->
state
,
"FINISHED"
);
free_memory
(
memory_list
,
processing
);
// move finished process from input list
move_node
(
input_list
,
processing
);
// add all process except this cycle
//pickup_input(batch_list, input_list, simulated_time-quantum);
int
proc_remaining
=
count_list
(
input_list
);
printf
(
"%d,%s,process_name=%s,proc_remaining=%d
\n
"
,
simulated_time
,
processing
->
state
,
processing
->
process_name
,
proc_remaining
);
// add all process
...
...
@@ -482,7 +483,7 @@ int allocate_memory(queue_memory* q, process_n* process, int simulated_time){
// printf("count_memory = %d \n",count_memory);
// check the memeory size
if
(
count_memory
<
process
->
memory
){
if
(
count_memory
<
process
->
memory
&&
min_end
==
NULL
){
return
0
;
}
if
(
count_memory
==
process
->
memory
){
...
...
@@ -508,6 +509,7 @@ int allocate_memory(queue_memory* q, process_n* process, int simulated_time){
printf
(
"%d,READY,process_name=%s,assigned_at=%d
\n
"
,
simulated_time
,
process
->
process_name
,
temp_start
->
number
);
return
1
;
}
else
if
(
count_memory
>
process
->
memory
){
//printf("compare\n");
if
(
min
==
-
1
){
min
=
count_memory
;
min_start
=
temp_start
;
...
...
@@ -522,6 +524,7 @@ int allocate_memory(queue_memory* q, process_n* process, int simulated_time){
}
}
}
//printf("min satrt = %d, min end = %d\n",min_start->number, min_end->number);
//printf("bug2\n");
int
position
=
find_position
(
min_start
,
q
);
...
...
@@ -678,6 +681,7 @@ process_n* search_shortest_process(queue_n* q){
// receive two list, put the process which arrived time is <= simulated_time
void
pickup_input_task3
(
queue_n
*
batch_list
,
queue_n
*
input_list
,
int
simulated_time
,
queue_memory
*
memory_list
){
process_n
*
temp
=
batch_list
->
head
;
while
(
temp
!=
NULL
)
{
//find arrive time <=> simulated-time
if
(
temp
->
arrival_time
<=
simulated_time
){
...
...
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