没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > protothread |
protothread
|
1 | 0 | 21 |
贡献者 | 讨论 | 代码提交 |
Protothreads is a programming model invented by Adam Dunkels that combines the advantages of event-driven (sometimes also called state machine) programming and threaded programming. The main advantage of the event-driven model is efficiency, both speed and memory usage. The main advantage of the threaded model is algorithm clarity. Protothreads gives you both. A protothread is an extremely lightweight thread. As with event-driven programming, there is a single stack; but like threaded programming, a function can (at least conceptually) block. This protothreads implementation:
is not an implementation of POSIX threads or any other standard API does not require assembly-language code or use setjmp/longjmp is independent of CPU architecture schedules threads non-preemptibly and deterministically. does not take advantage of multiple CPUs or cores
I designed and wrote the version described here from scratch and it is not compatible with other versions of protothreads. The only aspect of the implementation described here that is not standard C is its use of gcc label variables.
This project includes:
full source code (about 400 lines including comments) two synchronization facilities built on top of the base protothreads (semaphores and locks) about 800 lines of test code gdb (debugger) macros to print the stack traces of a given protothread or all protothreads.
Please see the wiki page for this project for more information.