-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScheduler.h
86 lines (73 loc) · 1.75 KB
/
Scheduler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
//
// Scheduler.h
// T1
//
// Created by Guillermo Figueroa and Juan Cortés on 8/16/17.
// Copyright © 2017 Guillermo Figueroa and Juan Cortés. All rights reserved.
//
#ifndef Scheduler_h
#define Scheduler_h
#include <stdio.h>
#include "Queue.h"
/** @defgroup scheduler Scheduler
* @brief The Scheduler and all the elements related
*/
/**
* @ingroup scheduler
* @brief Declarations of the scheduler
*/
struct Scheduler {
/**
* The processes that are ready and can be executed
*/
Queue* ready_queue;
/**
* The processes that are waiting. The priority corresponds to when the element needs to leave the queue
*/
Queue* waiting_queue;
/**
* The process that's being executed
*/
Process* process_in_execution;
/**
* The amount of time that the process has been being executed
*/
int time_process;
};
typedef struct Scheduler Scheduler;
/**
* @ingroup scheduler
* @brief Initialize the scheduler with the type provided
*
* @param type The type of the queue:
* 0: is for FCFS
* 1: is for ROUNDROBIN
* 2: is for PRIORITY
*
* @return The scheduler that has been initalized
*/
Scheduler* init_scheduler(int type);
/**
* @ingroup scheduler
* @brief Schedule a process to be done
*
* @param scheduler The scheduler that's going to be used
* @param process The process that's going to be scheduled
*
*/
void schedule(Scheduler* scheduler, Process* process);
/**
* @ingroup scheduler
* @brief Simulate one unit of time
*
*/
void tick(Scheduler* scheduler);
/**
* @ingroup scheduler
* @brief Free the memory allocated by the scheduler
*
* @param scheduler The scheduler that's going to be freed
*
*/
void free_schedule(Scheduler* scheduler);
#endif /* Scheduler_h */