|
Protothreads第一个程序(IAR,GCC共用一份代码),两个任务,控制LED闪烁。
编译输出目录:
IAR是debug,
gcc+avr_studio是default,
gcc+makefile是output。
点击此处下载ourdev_193336.rar(文件大小:92K)
实际上Protothreads只是几个宏文件,就能实现线程切换,一个函数都没有。
我移植AVR上加上一个pt_ticks.c文件。整个系统不到200字节。
usmartx可以不用了,以后就用Protothreads了。
Protothreads - Lightweight, Stackless Threads in C
http://www.sics.se/~adam/pt/
Protothreads are extremely lightweight stackless threads designed for
severely memory constrained systems such as small embedded systems or
sensor network nodes. Protothreads can be used with or without an
underlying operating system.
Protothreads provides a blocking context on top of an event-driven
system, without the overhead of per-thread stacks. The purpose of
protothreads is to implement sequential flow of control without
complex state machines or full multi-threading.
Main features:
* No machine specific code - the protothreads library is pure C
* Does not use error-prone functions such as longjmp()
* Very small RAM overhead - only two bytes per protothread
* Can be used with or without an OS
* Provides blocking wait without full multi-threading or
stack-switching
* Freely available under a BSD-like open source license
Example applications:
* Memory constrained systems
* Event-driven protocol stacks
* Small embedded systems
* Sensor network nodes
The protothreads library is released under an open source BSD-style
license that allows for both non-commercial and commercial usage. The
only requirement is that credit is given.
The protothreads library was written by Adam Dunkels <adam@sics.se>
with support from Oliver Schmidt <ol.sc@web.de>.
More information and new versions can be found at the protothreads
homepage:
http://www.sics.se/~adam/pt/
Documentation can be found in the doc/ subdirectory.
Two example programs illustrating the use of protothreads can be found
in this directory:
example-small.c A small example showing how to use protothreads
example-buffer.c The bounded buffer problem with protothreads
example-codelock.c A code lock with simulated key input
To compile the examples, simply run "make".
Adam Dunkels, 3 June 2006 |
阿莫论坛20周年了!感谢大家的支持与爱护!!
一只鸟敢站在脆弱的枝条上歇脚,它依仗的不是枝条不会断,而是自己有翅膀,会飞。
|