Runtime abstraction

I am asked to write a program that abstracts execution scheduling algorithms in C. I am having a problem with "priority scheduling". It takes the user from time to time, just like other algorithms, except that it also takes priorities from these processes. What worries me is that I cannot tie priorities to battery life. How can I establish a relationship between priority and runtime? According to the algorithm, it starts the first one with the highest priority. I just need to know how to make this connection, thanks.

+3


source to share


1 answer


EDIT: -

Store the priorities in an array and sort the array according to decreasing priorities and map each priority to that deadline! Then just display the sorted array from start and match against process-time.

If a process is added at runtime, you need to adopt a greedy algorithm to solve this problem. Select this process with the highest priority in ascending order of incoming time.

Check it out to learn more Interval Scheduling Algorithm



BTW, to implement the real scheduling algorithm: -

  • If the first process is started and then a new process appears with the same or lower priority level, then you should only add the new process to the FIFO (queue) data structure so that it runs on the next one (for equal / lower priority).

  • If the first process is currently running, and a new higher priority process arrives and requests memory, you must pass the current "upcoming instruction on the stack" command and execute the higher priority process, then return an interrupt to execute the upcoming instruction!

Hope you are embarrassed DATA-STRUCTURES

to implement peculiarly. Also, there is significant use of priority (above)!

+1


source







All Articles