Question:
Can you please help me with answering the following coding question? If you do write code, can it please either be in C or C++? Thank you
Problem:
Your task is to create the CPU execution scheduler where the jobs are kept in a priority queue implemented as a binary heap. Make this a round robin type of execution where the jobs are deleted from the heap, executed for 2 time units, and re-inserted with a lower priority into the priority queue. Jobs that have completed execution would not be re-inserted into the heap. New jobs could come in at a priority that might be higher than the aging jobs. .
For example, the following tree represents a Maximum binary heap. Each node indicates the priority and the total execution time of each process. This a round robin type of execution where the jobs are deleted from the heap, The system assigns the next CPU time (time slice) which is 2 unit to the highest priority process.
Here, the root will be deleted and will be executed for two units of time. In the following example 8 gets deleted from the binary heap. It gets executed for 2 unit of time, as a result 6 will be its new priority and the new execution time as well. It will be re-inserted into the heap
As long as the total execution time is greater than 0, the task with be reinserted into the binary heap and will be allocated according to its new priority. If two process has the same priority, the system can pick either one.
Code should contain the following functions:
1. Create Binary Tree, 2. Delete, 3. Scheduling, 4. Insertion, 5. Heapify