Please let go of that example. It is only confusing you and is not the way things are actually done.If this specification make sense to you then how would you schedule the all tasks based on preemptive multitasking?
Task 1
- Task 1 execute once for 500 ms
- Task 1 has lowest priority
- Deadline 1000 ms
Task 2
- Task 2 execute once for 50 ms
- Task 2 has Middle priority
- Deadline 100 ms
Task 3
- Task 3 execute once for 5 ms
- Task 3 has highest priority
- Deadline 10 ms
When the Task 3 is ready, it will preempt anything running. And the Task 2 will preempt the Task 1 if it is ready.
If anyone can fill in the table that is great it will give me complete idea.
Code:0 5ms ------> Task 3 is running because it has highest priority 10ms -----> Task 2 is running because it is next high priority task 15ms -----> Task 3 running, Task 2 is interrupted by Task 2 before it has finished
It's a classic. First you fall in love, then you get a broken heart, that love ruined your life. Much of the complexity in OS scheduling is designed to prevent a broken heart from priority abuse.OP is in love with priority.
The Windows OS scheduler is a very well designed system (designed initially by Dave Cutler) I want to suggest you get a copy of this book as it is very detailed and will explain a lot of intricacies about this subject, it will explain all you need to know about the principles involved in scheduling and multitasking and it covers multiple processors too.If this specification make sense to you then how would you schedule the all tasks based on preemptive multitasking?
Task 1
- Task 1 execute once for 500 ms
- Task 1 has lowest priority
- Deadline 1000 ms
Task 2
- Task 2 execute once for 50 ms
- Task 2 has Middle priority
- Deadline 100 ms
Task 3
- Task 3 execute once for 5 ms
- Task 3 has highest priority
- Deadline 10 ms
When the Task 3 is ready, it will preempt anything running. And the Task 2 will preempt the Task 1 if it is ready.
If anyone can fill in the table that is great it will give me complete idea.
Code:0 5ms ------> Task 3 is running because it has highest priority 10ms -----> Task 2 is running because it is next high priority task 15ms -----> Task 3 running, Task 2 is interrupted by Task 2 before it has finished
The specific way that preemptive scheduling is implemented is quite fascinating. It requires that code be able to execute at some higher privilege ("kernel mode" say) and have a stack that is separate from "user mode" stacks.Happy New Year to all
ok maybe i got it. Preemptive multitasking allocates CPU time for each task and interrupts the task to schedule CPU time for another task waiting for execution.
There are many algorithms based on preemptive scheduling such as given in this page https://www.google.com/amp/s/www.geeksforgeeks.org/preemptive-and-non-preemptive-scheduling/amp/
I’m re-learning along with this thread, since it’s been almost 50 years since I’ve covered the topic in class.Understood we need to select the algorithm that the project requires.
Round-robin algorithm is a pre-emptive algorithm. It is used in many projects
I am planning to write C code for round-robin type pre-emptive scheduler. I will create new thread for this. For now it will take some time as I haven't done much research on it yet.
djsantasi,My co-operative multitasking program uses a variety of methods