3

I want to implement Earliest deadline scheduling in C but I cant find the algorithm on the net..

I understand the example below that when time is 0, both A1 and B1 arrive. Since A1 has the earliest deadline, it is scheduled first. When A1 completes, B1 is given the processor.when time is 20, A2 arrives. Because A2 has an earlier deadline than B1, B1 is interrupted so that A2 can execute to completion. Then B1 is resumed when time is 30. when time is 40, A3 arrives. However, B1 has an earlier ending deadline and is allowed to execute to completion when time is 45. A3 is then given the processor and finishes when time is 55.. However I cant come up with a solution.. Please help me to find an algorithm. Thanks..

Image of the example

example http://imageshack.us/photo/my-images/840/scheduling.png/

Sam
  • 1,501
  • 3
  • 19
  • 27
user974267
  • 31
  • 1
  • 3

2 Answers2

4
  • when a process finishes (and at the beginning), take the process with the lowest processTimeToDeadline - processTimeToExecute as the new current process
  • When a new process arrives, replace the current process if and only if newProcessTimeToDeadline - newProcessTimeToExecute < currentProcessTimeToDeadline - currentProcessTimeStillNeededToExecute.

Note: if you do this with multiple CPU, you got the Multiprocessor scheduling problem, which is NP complete.

Geoffrey De Smet
  • 22,431
  • 8
  • 59
  • 106
0

Previous answer describe "Earliest Feasible Deadline First" (EFDF) scheduler and it fist perfectly to image from qestion. "Earliest Deadline First" (EDF) scheduler is more simple. Scheduler just run task with earliest deadline. And it is all.

  • 1
    Could you please elaborate? Thanks. – galath Aug 09 '15 at 08:58
  • Better than elaborate is reference to this [(IJACSA) International Journal of Advanced Computer Science and Applications, Vol. 2, No.2, February 2011-An Algorithm to Reduce the Time Complexity of Earliest Deadline First Scheduling Algorithm in Real-Time System](http://thesai.org/Downloads/Volume2No2/Paper%207-An%20Algorithm%20to%20Reduce%20the%20Time%20Complexity%20of%20Earliest%20Deadline%20First%20Scheduling%20Algorithm%20in%20%20%20Real-Time%20System.pdf) – Jiri Dobry Aug 09 '15 at 09:42