Multithreading using C on PIC18

M3. picture M3. · Oct 26, 2009 · Viewed 8.4k times · Source

How does one create threads that run in parallel while programming PIC18, since there is no OS?

Answer

janm picture janm · Oct 26, 2009

Don't use threads, use an event loop.

The PIC18 is a small processor and an event loop based style means you don't have to keep many deep stacks hanging around. You need to write your code in terms of the event loop, but that is probably reasonable.

If you do have some long running tasks, use timers are different interrupt priority levels to allow higher priority event loops to preempt lower priority event loops, and put appropriate types of work into the appropriate event queue.