??? 01/29/05 00:55 Read: times |
#86078 - Scheduler Responding to: ???'s previous message |
Ian, Generally, whenever a RTOS is mentioned, it tends to imply a pre-emptive task switcher - Real Time suggests that tasks will be activated in a timely and consistant manner. A co-operative tasker I would not call a RTOS. I doubt if I would call my priority system 'fancy'! By fancy, I mean round robin,priority inversion etc. He's how I do it in 'c' and it's also quite easy to code in assembler and compact! [pre] while(1) { if (tick_flag != 0) { tick_flag=0; kick_dog(); task_dispatch(); // well.... } } } // // reload the watchdog timer so he doesn't reset us.... // void kick_dog(void) { EA = 0; //put watchdog reload code in here EA = 1; } void task_dispatch(void) { // scan the task bits for an active task and execute it char xtask; /* take care of the task timers. if the value ==0 skip it else decrement it. If it decrements to zero, activate the task associated with it */ xtask = 0; while (xtask < NUM_TASKS ) { if (task_timers[xtask] !=0 ) { task_timers[xtask]--; /* dec the timer */ if (task_timers[xtask] == 0 ) set_task(xtask); /* if ==0 activate the task bit */ } xtask++; } xtask=0; /* start at the most significant task */ while (xtask < NUM_TASKS ) { if ((task_bits & bit_mask[xtask]) != 0 ) break; /* if activate task found..*/ xtask++; /* else try the next one */ } switch(xtask) /* if task bit is active..execute the task */ { case 0: task0(); break; case 1: task1(); break; case 2: task2(); break; case 3: task3(); break; case 4: task4(); break; case 5: task5(); break; case 6: task6(); break; case 7: task7(); break; default: break; /* no task was active!! */ } } /***************************************************************************************** Sets the run flag for the supplied task number. be sure not to pass a task# > 7 as the number is masked and will wrap around! ******************************************************************************************/ void set_task(char tsk) { EA=0; /* no interrupts */ task_bits |= bit_mask[tsk]; /* sets a task bit */ EA=1; } /***************************************************************************************** Resets the run flag for the supplied task number. ******************************************************************************************/ void reset_task(char tsk) { EA=0; task_bits &= (~bit_mask[tsk]); /* resets a task bit */ EA=1; } void T0_int(void) interrupt 1 { static data char ticker = 0; TR0=0; TL0 = (1 - TIME_TICK); TH0 = (1 - TIME_TICK)>>8; TR0=1; /* set the timer running */ if (ticker !=0) { ticker--; } else { tick_flag=1; /* set the tick flag */ ticker = 10; } } [/pre] |
Topic | Author | Date |
Computed Call | 01/01/70 00:00 | |
Computed Call | 01/01/70 00:00 | |
simulate an LCALL @A+DPTR instruction? | 01/01/70 00:00 | |
Solution | 01/01/70 00:00 | |
Computed LCALL | 01/01/70 00:00 | |
Computed LCALL | 01/01/70 00:00 | |
Table offset | 01/01/70 00:00 | |
x2, not x3 | 01/01/70 00:00 | |
what is the problem | 01/01/70 00:00 | |
My Problem | 01/01/70 00:00 | |
never heard of it | 01/01/70 00:00 | |
It is....... | 01/01/70 00:00 | |
RTOS | 01/01/70 00:00 | |
8051 RTOs Limitations/Issues/Opportunity | 01/01/70 00:00 | |
How? | 01/01/70 00:00 | |
Decisions, decisions | 01/01/70 00:00 | |
Small systems - task scheduling | 01/01/70 00:00 | |
Worth it? | 01/01/70 00:00 | |
Scheduler | 01/01/70 00:00 | |
Scheduler | 01/01/70 00:00 | |
running small in a big way | 01/01/70 00:00 | |
Example | 01/01/70 00:00 | |
in very small chips | 01/01/70 00:00 | |
In all sorts of sizes of chips | 01/01/70 00:00 | |
time dependednt | 01/01/70 00:00 | |
RTOS or Not | 01/01/70 00:00 | |
opinion piece | 01/01/70 00:00 | |
fact piece | 01/01/70 00:00 | |
Opinion piece | 01/01/70 00:00 | |
suggestion piece | 01/01/70 00:00 | |
reasons | 01/01/70 00:00 | |
Polite discussion | 01/01/70 00:00 | |
Politeness | 01/01/70 00:00 | |
Thanks | 01/01/70 00:00 | |
Politeness | 01/01/70 00:00 | |
What are you Rabbiting on about? | 01/01/70 00:00 | |
Close but no Cigar | 01/01/70 00:00 | |
Rabbit food | 01/01/70 00:00 | |
Plessey | 01/01/70 00:00 | |
small world | 01/01/70 00:00 | |
Smaller than you imagine!![]() | 01/01/70 00:00 | |
I use the computed LCALL ... | 01/01/70 00:00 | |
go it | 01/01/70 00:00 | |
Call tabs in-line | 01/01/70 00:00 | |
abbreviated | 01/01/70 00:00 | |
... and further optimized... | 01/01/70 00:00 | |
has been already disscussed | 01/01/70 00:00 | |
Scheduler of course | 01/01/70 00:00 | |
Scheduler | 01/01/70 00:00 |