问题描述
在编写时,如何创建并行运行的线程?不是操作系统?
How does one create threads that run in parallel while programming PIC18, since there is no OS?
推荐答案
不要使用线程,使用事件循环。
Don't use threads, use an event loop.
PIC18是一个小型处理器,基于事件循环的风格意味着您不必保留许多深层堆叠。您需要根据事件循环编写代码,但这可能是合理的。
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.
这篇关于在PIC18上使用C的多线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!