Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
comp30023-2021-project-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
Elizabeth Baker
comp30023-2021-project-1
Commits
c7f214d4
Commit
c7f214d4
authored
4 years ago
by
Elizabeth Baker
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/master' into alternative_ending
# Conflicts: # allocate.c
parents
b47675d8
4867c68c
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
+15
-6
15 additions, 6 deletions
allocate.c
with
15 additions
and
6 deletions
allocate.c
+
15
−
6
View file @
c7f214d4
...
@@ -20,12 +20,14 @@ typedef struct {
...
@@ -20,12 +20,14 @@ typedef struct {
int
timeRemaining
;
int
timeRemaining
;
int
subProcsRunning
;
int
subProcsRunning
;
int
justStarted
;
int
justStarted
;
int
deltaTime
;
}
process
;
}
process
;
typedef
struct
{
typedef
struct
{
//int CPUi;
//int CPUi;
int
totalExecutionTimeRemaining
;
//add all the times of the process
int
totalExecutionTimeRemaining
;
//add all the times of the process
llist
*
processQueue
;
llist
*
processQueue
;
int
numPorc
;
}
CPU
;
}
CPU
;
void
initializeProcess
(
char
data
[],
process
*
newProcess
);
void
initializeProcess
(
char
data
[],
process
*
newProcess
);
...
@@ -176,8 +178,8 @@ int main(int argc, char *argv[]) {
...
@@ -176,8 +178,8 @@ int main(int argc, char *argv[]) {
if
(
headProcess
!=
NULL
&&
headProcess
->
justStarted
)
{
if
(
headProcess
!=
NULL
&&
headProcess
->
justStarted
)
{
// printf("current time: %d\n", currentTime);
// printf("current time: %d\n", currentTime);
headProcess
->
justStarted
=
0
;
headProcess
->
justStarted
=
0
;
printf
(
"%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d
\n
"
,
printf
(
"%d,RUNNING,pid=%s,remaining_time=%d,cpu=%d
- AAAA line 184
\n
"
,
current
Time
,
headProcess
->
processID
,
headProcess
->
timeRemaining
,
j
);
delta
Time
+
1
,
headProcess
->
processID
,
headProcess
->
timeRemaining
,
j
);
}
}
}
}
...
@@ -291,7 +293,7 @@ void initializeProcess(char data[], process *newProcess) {
...
@@ -291,7 +293,7 @@ void initializeProcess(char data[], process *newProcess) {
if
(
token
!=
NULL
)
{
if
(
token
!=
NULL
)
{
newProcess
->
parallelisable
=
token
[
0
];
newProcess
->
parallelisable
=
token
[
0
];
}
}
newProcess
->
deltaTime
=
0
;
newProcess
->
timeCompleted
=
-
1
;
newProcess
->
timeCompleted
=
-
1
;
newProcess
->
timeRemaining
=
newProcess
->
executionTime
;
newProcess
->
timeRemaining
=
newProcess
->
executionTime
;
}
}
...
@@ -355,7 +357,11 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
...
@@ -355,7 +357,11 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
}
}
llist_pop
(
processQueue
);
llist_pop
(
processQueue
);
headProcess
=
headData
(
processQueue
);
headProcess
=
headData
(
processQueue
);
if
(
headProcess
)
headProcess
->
justStarted
=
-
1
;
if
(
headProcess
){
headProcess
->
justStarted
=
-
1
;
headProcess
->
deltaTime
=
deltaTime
;
}
}
else
{
// finishedprocess is not parallelisable
}
else
{
// finishedprocess is not parallelisable
*
numProcessesLeft
-=
1
;
*
numProcessesLeft
-=
1
;
*
numProcessComplete
+=
1
;
*
numProcessComplete
+=
1
;
...
@@ -365,12 +371,15 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
...
@@ -365,12 +371,15 @@ void advanceProcessQueue(llist *processQueue, int currentTime, int deltaTime, ll
llist_push
(
processesComplete
,
headProcess
);
llist_push
(
processesComplete
,
headProcess
);
llist_pop
(
processQueue
);
llist_pop
(
processQueue
);
headProcess
=
headData
(
processQueue
);
headProcess
=
headData
(
processQueue
);
if
(
headProcess
)
headProcess
->
justStarted
=
-
1
;
if
(
headProcess
){
headProcess
->
justStarted
=
-
1
;
headProcess
->
deltaTime
=
deltaTime
;
}
}
}
}
else
{
// head process not finished
}
else
{
// head process not finished
headProcess
->
timeRemaining
-=
deltaTime
;
headProcess
->
timeRemaining
-=
deltaTime
;
headProcess
->
deltaTime
=
deltaTime
;
deltaTime
=
0
;
deltaTime
=
0
;
// llist_print( processQueue, (void (*)(void *)) &printQEntry );
// llist_print( processQueue, (void (*)(void *)) &printQEntry );
}
}
...
...
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