Last week there was some discussion regarding copying the PIC18 stack. I started the thread to look at multitasking. Well, I've got some beginning code in C18 that seems to work. I'm sure it can be improved (for example, I'm restoring stack position 0, even though it does not exist). But, it seems to work. I'd appreciate comments. It's at http://www.piclist.org/techref/microchip/language/c/MultiTask.c.htm . Next project is intertask communications. In the past (on MC6800 and 80286), I've had a fifo for each task that was on the task's "input." Any task could deposit a message on another task's input fifo. When that task's turn came up, it would read any messages off the fifo, process them (generally creating messages for other task input fifos). Messages were always "complete" before they were sent so we would not get a partial message from one task and a partial from another. This, however, resulted in a lot of ram being wasted since most of the time all these fifos were empty. I'm wondering about maybe having a single fifo that is the input to all tasks. Any task would place messages in this fifo. When a task resumes, it would see if the first message in the fifo was for it. If not, it would exit and allow the next task to run, which would also check the first message in the fifo. Messages would be pulled off the fifo in order so we don't end up having to keep track of empty spaces in the fifo. This may result in the system locking up, but it SEEMS like as long as each task pulls a message off the fifo every time the task runs, it should work. The only time a task would exit would be when the first message in the fifo is NOT addressed to this task. So... that's my current thinking. Comments? 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