??? 09/01/04 13:45 Read: times Msg Score: 0 +2 Good Answer/Helpful -1 Answer is Wrong +1 Informative -2 Overrated |
#76753 - \ |
Many are fascinated by "multitasking" and come up with all kinds of timer controlled 'slicing'.
The ONLY reason I can see for "multitasking" would be not to allow any single process to hog the processor. For that purpose there is absolutely no need to employ 'time slicing' I have, in many cases, developed workloops that call the processes sequentially and state 3 things for the processes: 1) if you have nothing to do GET OUT 2) no waitloops, if you need to wait GET OUT and check next time 3) if your process is lenghty, SPLIT IT UP Here is an example of a simple "multitasking" process that, by not allowing any 'task' to hog the system (see task2) makes sure that all get executed in a reasonable time for(;;) { task1(); task2(); task3(); task4(); } void task1(void) { //this is a simple task, just do it when needed if (!T2active) return; .... } void task2(void) { // this task process a zero terminated character string // when available and is 'sliced' in order not to // hog the processor switch (T2state) case 0: // nothing to do if (*cptr !=0) { T2state = 2; } break case 2: // process ONE character .... cptr++ if (*cptr ==0) { T2state = 0; } } The 'slicing' shown for task2 is very simple, but I have employed it an many other ways without undue complexity. Now for the priority task: set a bit that causes an interrupt (e.g. TF2 if timer 2 ius not used). That interrupt is set to a priority lower than all hardware caused interrupts. This effectively create a process that will execute regardless of main() and only halt when interrupts occur. Erik |
Topic | Author | Date |
\ | 01/01/70 00:00 | |
"Multitasking" with no traps | 01/01/70 00:00 | |
Title | 01/01/70 00:00 | |
RE: Multitasking with no traps | 01/01/70 00:00 | |
RE: Multitasking with no traps | 01/01/70 00:00 | |
RE: Multitasking with no traps | 01/01/70 00:00 | |
RE: soft interrupts | 01/01/70 00:00 | |
RE: \ | 01/01/70 00:00 | |
RE:I would like to know | 01/01/70 00:00 | |
true, but there are times when | 01/01/70 00:00 | |
RE: true, but there are times when | 01/01/70 00:00 | |
No, I am using SDCC | 01/01/70 00:00 | |
Never seen such times. | 01/01/70 00:00 | |
RE: Never seen such times. | 01/01/70 00:00 | |
OS Advocate | 01/01/70 00:00 |