-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathroundrobin.h
51 lines (46 loc) · 1.6 KB
/
roundrobin.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
#ifndef ROUNDROBIN_H_INCLUDED
#define ROUNDROBIN_H_INCLUDED
typedef struct {
int process_id;
int arrival_time;
int burst_time;
int remaining_burst_time;
int io_wait_time; // I/O operations always happen after the process completes its burst time
int completion_time;
int turnaround_time;
int waiting_time;
int response_time;
int blocked_until;
bool is_completed;
bool in_queue;
bool is_ready;
bool is_running;
bool is_blocked;
} Process;
typedef struct {
int time;
int process_id;
int remaining_burst_time;
int io_wait_time;
int remaining_time;
char status[10]; // Store status like "READY", "RUNNING", "BLOCKED", "COMPLETED"
} ProcessStatusLog;
typedef enum {
READY,
RUNNING,
BLOCKED,
COMPLETED
} Status;
void check_positive_integer(const char* prompt, int* value);
void initialize_processes(Process processes[], int num_processes);
void sort_processes_by_arrival_time(Process processes[], int num_processes);
void sort_processes_by_process_id(Process processes[], int num_processes);
void check_for_new_arrivals(int *current_time, Queue *ready_queue);
void check_blocked_processes(int *current_time, Queue *ready_queue, int *blocked_processes);
void update_queue(Queue *ready_queue, int *current_time, int *executed_processes, int *blocked_processes);
void round_robin_scheduler();
void output_process(int current_time, int process_id, Status process_status, int remaining_burst_time, int io_wait_time);
void output_results();
void print_gantt_chart(Process p[], int n);
void export_analysis_to_file();
#endif // ROUNDROBIN_H_INCLUDED