I have an assignment where I need to develop a simulation of a process scheduler:
Assume that your computing infrastructure has 5 processors available. Now consider n = 100 processes with different runtime requirements. Specifically, each process has associated with it a burst time (processing time) and a memory requirement. Burst-times are assigned at random (10 * 106 cycles — 50 *1012 cycles). Memory requirements are assigned at random (.25 MB — 8GB). You may assume that the set of 100 processes is known a-priori; hence, you will have to develop a function that can generate this set with random burst-times and memory requirements. For this project we will only explore the use of non-preemptive scheduling methods. Suppose that all 5 processors are identical (i.e., same speed and memory), develop and implement a scheduling algorithm that assigns the set 100 processes to the 5 processors such that the total turnaround time to complete all 100 processes is minimized.
I got most of it setup but I am stuck at figuring out the logic to actually schedule the processes. Right now I have a struct created that holds processes with their pid, cycle count and memory requirement. And I have used a vector to hold all the 100 processes so I can sort them if I want to and remove processes as I schedule them.
For the 5 processors I just created an int array but I am guessing the processors should have cycle count and memory limits? In that case another struct maybe?
And how would I actually assign processes to these 5 processors? Can someone help me figure that out? I just need to implement a simple FCFS algorithm.
void init_process_list(vector<process> &p_list) {
generator generate; // Random number generator class
process p;
for(int i = 0; i < process_count; i++) {
p.process_id = i;
p.cpu_cycles = generate.rand_num_between(cycle_lbound, cycle_ubound);
p.mem_footprint = generate.rand_num_between(mem_lbound, mem_ubound);
p_list.push_back(p);
}
}
// Initialize processor array
void init_processor_list(int *processor_list) {
for(int i = 0; i < processor_count; i++)
processor_list[i] = 0;
}
void schedule_processes(vector<process> &p_list, int *processor) {
}
int main() {
vector<process> process_list;
int cpu[processor_count];
init_process_list(process_list);
init_processor_list(cpu);
schedule_processes(process_list, cpu);
}
Aucun commentaire:
Enregistrer un commentaire