Guest
#1254854
I'm working on a project to implement a simple, priority based, rate monotonic real-time task scheduler. I already completed task structures, task creation function and task scheduling algorithm. Scheduler works with timer interrupt periodically. Then it decides which task to run in next time slice. My problem is as follows, I want to make my scheduler pre-emptive. So while task-1 is running, and scheduler runs with interrupt, and if it decides task-1 should wait and task-2 should work in next time slice, I need to do context saving. Stop executing task-1 and run task2. But I can not figure out how to do this exactly. Because when timer interrupt occurs and timer-1 pauses for a while, normally after the interrupt handler function completes, program counter will return back to last execution address of task-1. But probably I won't want to program counter return back to task-1 after scheduler execution on timer-1, I might want it to jump to task-2 instaad of task-1. So, I think I have to take all control of interrupt mechanism and do returns etc manually. What do you suggest me to read and try?