Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

basic scheduler program

Status
Not open for further replies.

vead

Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,815
Hello everyone

There are two type of interrupt, hardware ans software interrupt. When we have to do any task at any specific time, we use timer interrupts like if we have to do task after 1 second then we will set timer interrupt. interrupt will occur at every 1 second. Hardware interrupt like if any event happen interrupt will generate such as if any switch press turn on the motor. interrupt will happen at every switch press.

Scheduling decide which task should execute at this time. My understanding say that we set the timer interrupt for every tasks.

set interrupt for 10 ms (task 1)
set interrupt for 12 ms (task 2)
set interrupt for 15 ms (task 1)

We set priority for every task's

first priority (task 3)
second priority (Task 2)
third priority (Task 1)

I have the knowledge of timer interrupt and priority. if I want to make basic scheduler program then what's the programming knowledge required to implement simple scheduler
 

Software interrupts are only available on a limited number of processors. I think what you probably need to do is use a hardware timer interrupt to keep a software clock running so you can hook your tasks to it and start them as needed. Find the longest period common to all your timing requirements then count the periods in an ISR.

Brian.
 

Software interrupts are only available on a limited number of processors. I think what you probably need to do is use a hardware timer interrupt to keep a software clock running so you can hook your tasks to it and start them as needed. Find the longest period common to all your timing requirements then count the periods in an ISR.

Brian.

Okay but my Question was what what's the programming skill required to implement simple scheduler. I know the interrupt and structure. Is it sufficient to make simple scheduler. What's the skill need to make simple scheduler
 

Depending on the processor you are using, you may well have to set aside enough storage for each task to save the complete register set - at least of the CPU. Some devices I know of allow registers to be set but not read (e.g. some of the PIC registers associated with repeated instructions for the DSP operations). Therefore it can be quite hard to save the state of the device completely for a general case - if you know that you will never write code or use a library that uses the 'special' registers then you can leave them out of the context switch.
As for the scheduling, so you want this purely based of the timer (preemptive) or can the tasks relinquish the processor when it knows it has nothing to do (cooperative)?
Either way, you need to maintain the state of each task and then regularly check to see if it is the highest priority task at that time that can run. A common way of doing this is to have a list of tasks in the order they can be run - be that timer base, priority based or both.
Each 'heartbeat' you need to scan the list and see if the top-most task that can run is the current task or not - if not then a context switch is required and the task list re-ordered.
In the example you provided, your heartbeat would need to be every 1msec if that is the time slice resolution you want to achieve.
Personally I would investigate an existing piece of software such as RTOS (there are a number of alternatives) which are free and have the development (and general support) available without having to reinvent the wheel.
Susan
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top