-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocesos_functions.h
More file actions
74 lines (55 loc) · 2.21 KB
/
procesos_functions.h
File metadata and controls
74 lines (55 loc) · 2.21 KB
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
#include <stdio.h>
#include <conio.h>
#include <locale.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>
#include <stdbool.h>
// Defines process structure (struct ~ object/class)
struct Process {
char title[20];
float timeLeft;
char status[10];
int priority;
};
// Enums
enum Algorithm {
ROUND_ROBIN = 1,
PRIORITY = 2,
FIFO = 3
};
enum LoadingMethod {
MANUAL = 1,
TXT = 2
};
// -- Function Prototypes --
// Clears input buffer
void clearInputBuffer();
// Manages the cration of processes lists and algorithm choosing
void initProcessScheduler();
// Asks the user for project values and creates it
struct Process createProcessByUserInput();
// Populates the processesList, requires the list to be created with a specified size previously
void populateProcessesListByUserInput(struct Process processesList[], int initialProcessesQuantity);
// Populates the processesList getting the data from a .txt file (previously created)
void populateProcessesListByTxt(struct Process processesList[], int initialProcessesQuantity);
// Adds a process to the list by replacing a completed one - Not in use currently
void addNewProcess(struct Process processesList[], int processesQuantity);
// Starts processes planner with the selected algorithm
void runProcessesPlanner(struct Process processesList[], int processesQuantity, int chosenAlgorithm);
// Runs processes sequentially
void runProcesses(struct Process processesList[], int processesQuantity);
// Sorts the array by priority value (1 is most precedent)
void sortByPriority(struct Process processesList[], int processesQuantity);
// Runs Round Robin algorithm
void roundRobin(struct Process processesList[], int processesQuantity);
// Runs Priority algorithm
void priority(struct Process processesList[], int processesQuantity);
// Runs FIFO (First In First Out) algorithm
void fifo(struct Process processesList[], int processesQuantity);
// Prints all processes status
void printStatus(const struct Process processesList[], int processesQuantity);
// Checks if all processes are completed (only for RR)
bool checkCompletion(const struct Process processesList[], int length);
// Returns the algorithm name by the enum value
const char* getAlgorithmName(int chosenAlgorithm);