-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess.h
More file actions
55 lines (46 loc) · 1.56 KB
/
Copy pathprocess.h
File metadata and controls
55 lines (46 loc) · 1.56 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
#ifndef PROCESS_H
#define PROCESS_H
#include <stdbool.h>
typedef struct {
int pid; // Process ID
int arrival_time; // When process arrives
int burst_time; // Total CPU time needed
int priority; // Priority (lower number = higher priority)
// Calculated metrics
int remaining_time; // Time left to execute (for preemptive)
int completion_time; // When process finishes
int turnaround_time; // completion_time - arrival_time
int waiting_time; // turnaround_time - burst_time
int response_time; // first_run_time - arrival_time
int first_run_time; // When process first gets CPU
// For MLFQ
int queue_level; // Current queue level (0 = highest priority)
} Process;
// Gantt chart entry
typedef struct {
int pid;
int start_time;
int end_time;
} GanttEntry;
// Gantt chart structure
typedef struct {
GanttEntry *entries;
int count;
int capacity;
} GanttChart;
// Scheduling metrics
typedef struct {
double avg_waiting_time;
double avg_turnaround_time;
double avg_response_time;
double cpu_utilization;
double throughput;
int total_time;
} SchedulingMetrics;
// Function declarations
void init_process(Process *p, int pid, int arrival, int burst, int priority);
GanttChart* create_gantt_chart();
void add_gantt_entry(GanttChart *chart, int pid, int start, int end);
void free_gantt_chart(GanttChart *chart);
void print_gantt_chart(GanttChart *chart);
#endif // PROCESS_H