| ??? 04/20/02 21:00 Read: times |
#21978 - RE: pros and cons of using an OS |
Bahri,
The "round-robin" scheduling loop is a very common approach as Erik indicated. There are many variations. The simple loop is: dispatch_loop: call task1 call task2 call task3 call task4 jmp dispatch_loop Each task executes in order and at equal priority. It's not uncommon for these tasks to have a flag or variable that indicates whether of not to fire off. This indicator may be set as a function of interrupt service routines (i.e. message terminator rx'd on serial port set msg assemble and waiting flag) or by another task that has prepared input for another task. If tasks are ordered by priority each task can either fall thru to the next or jump back to the top as a function of whether they fired off or not. No work to do=fall thru, processing required then jump back to the top. dispatch_loop: call task1 ;<-- most critical task call task2 jc dispatch_loop call task3 jc dispatch_loop call task4 jmp dispatch_loop Another method is to have a counter for each task and when a task is dispatched it down-counts its task counter and executes when the counter expires. This allows some process tuning. You can even have the interrupt or another task jam load this counter if you are careful to state map the possible result. The all time quick and dirty priority scheme is to just multiply schedule an important task dispatch_loop: call task1 call task2 call task1 call task3 jmp dispatch_loop regards, p |



