Shop OBEX P1 Docs P2 Docs Learn Events
mutli threading — Parallax Forums

mutli threading

rizzorizzo Posts: 1
edited 2005-05-12 16:38 in BASIC Stamp
i was just wondering how to multi thread with pbasic. is there a specific command or what??

Comments

  • Paul BakerPaul Baker Posts: 6,351
    edited 2005-05-12 15:56
    There is no multithreading on the Stamp in the formal sense. The newer stamps have RUN slots which permit multiple banks of code to be switched between. You could also implement a multithreaded-esque scheduler program which parcels out processor time to various subroutines, each scheduling tick, the scheduler makes a decision which code section is executed and calls the code. Since there are no interupts in pbasic, you cannot implement a preemptive scheduler, so each code section called has to play nicely and return control to the scheduler within a reasonable amount of time.
  • allanlane5allanlane5 Posts: 3,815
    edited 2005-05-12 16:23
    Jon has a very nice template program in PBasic which lets you cycle a 'state-machine' which selects among several 'tasks'. In effect, this lets you have a multi-tasking program. However, since the multi-tasking is NOT built into the PBasic run-time, it can be VERY slow, and it does NOT support interrupts.

    If you added a nice external 50 mSec clock generator to it, you can even get predictable timing for your PBasic program.

    Otherwise, PBasic is ONLY a single-threaded, non-interrupt-driven run-time which does 2000 PBasic instructions per second. You might be amazed at how useful this can be.
  • BeanBean Posts: 8,129
    edited 2005-05-12 16:38
    If multitheading or interrupts are required look at the SX chips with the SX/B compiler.
    The SX does not support multithreading, but DOES support periodic interrupts.
    The SX also supports pin change interrupts.
    Or the SX is probably fast enough to use the 'state-machine' method also.
    Bean.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    "SX-Video Display Module" Available Now.

    www.sxvm.com

    "Great people talk about great things, average people talk about average things, small people talk about other people."
    ·
Sign In or Register to comment.