>>In FreeRTOS, a lower priority task only runs if all >>the higher priority tasks are sleeping. > > One scheme I have seen used in a co-operative OS is each task is assigned > a > priority number, the larger the number the lower priority of the task. > Then > as the task scheduler checks each task, it decrements the priority number > , > and when it reaches 0, that task is run. This means that even the lowest > priority task will eventually reach a point where it will get an > opportunity > to run, even with a large number of high priority tasks. When the task has > had an opportunity to run, and goes back to sleep, the OS reloads the > priority number with the original value, ready for the next round of > decrementing. > That's clever! I've just done cooperative multitasking before with equal priority. In my schemes (like http://www.piclist.org/techref/microchip/language/c/MultiTask.c.htm), a task runs until it gets stuck waiting for input. It then sits in a loop with NextTask() waiting for input. Once it has input, it runs until it again is waiting for input. On the output side, the tasks generally drive a fifo (often an input fifo for another task or for an I/O device), so they do not get stuck there unless the fifo fills. Harold -- FCC Rules Updated Daily at http://www.hallikainen.com - Advertising opportunities available! -- http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist