Protothreads for UNIX

Protothreads are a type of extremely lightweight threads – each protothread requires only two bytes of memory – that are usually used for embedded firmware programming, where memory is at a premium. Protothreads combine the low overhead with event-driven programming with the algorithmic clarity of threaded programming.

Larry Ruane from LeftHand Networks Inc. has written a protothreads library for Unix systems that, unlike Adam Dunkels’ original library, contains a complete scheduler that allows several protothreads to run inside a regular thread. Ruane’s protothreads are implemented in less than 400 lines of C code using gcc’s labels-as-values feature. The project wiki has a thorough explanation of how protothreads work and how they are intended to be used. The open source code can be downloaded from the project’s SourceForge page.

16 Comments

  1. kajaman 2009-01-18 12:32 pm EST
    • joshv 2009-01-18 12:50 pm EST
    • vivainio 2009-01-18 8:27 pm EST
      • PlatformAgnostic 2009-01-18 11:56 pm EST
        • vivainio 2009-01-19 3:25 pm EST
    • flanque 2009-01-18 8:29 pm EST
  2. madhatter 2009-01-18 1:24 pm EST
    • TechStorm 2009-01-18 2:54 pm EST
      • Vanders 2009-01-18 11:42 pm EST
    • ValiantSoul 2009-01-18 3:36 pm EST
      • helpfulhelper 2009-01-18 11:27 pm EST
  3. axilmar 2009-01-18 1:49 pm EST
    • adkilla 2009-01-18 3:05 pm EST
  4. antab 2009-01-19 5:48 am EST
    • LMRuane 2009-01-20 12:58 am EST
    • LMRuane 2009-01-20 5:51 am EST