ProtoThreads如何工作的.doc

  1. 1、本文档共5页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ProtoThreads如何工作的

ProtoThreads如何工作的 最近把手头的SD卡更新NK到NAND项目完成,总算抽空上网瞎逛游了。正好群里面有人推荐了一个系统,说是对小资源的单片机非常适合。这里我就推荐2篇网文: /bibis/moredata30_1234764_43130.shtml /t_larry/archive/2008/10/18/3097191.aspx 这2篇网文一个讲系统简介,一个是里面宏的说明。熟悉一下是很不错的。 然后就是官网了: http://www.sics.se/~adam/pt/index.html 我翻译了里面的under the hood?章节:How protothreads really work ? What goes on behind the magical macros in the C protothreads library? Why are they macros? How do the macros work? Read on for the explanation. 在C protothreads库里面的神奇宏到底发生了什么?他们为什么都是宏?这些宏是如何工作的?请接着读解释: ? In the C implementation of protothreads, all protothread operations are hidden behind C macros. The reason for building the protothread library on C macros rather than C functions is that protothreads alter the flow of control. This is typically difficult to do with C functions since such an implementation typically would require low-level assembly code to work. By implementing protothreads with macros, it is possible for them to alter the flow of control using only standard C constructs. 在Protothreads系统C的实现里,所有的protothread操作都被隐藏在C的宏里面。生成protothread库用C的宏而不是用C函数的原因是protothreads需要改变程序的跳转,这通常是很难用C函数做,因为这样的实现通常需要低级别的汇编代码的工作。通过protothreads宏的实施,它有可能只使用标准C结构为他们改变程序的跳转。 ? This page explains how protothreads work under the hood. We do this by taking a look at how the C preprocessor expands the protothread macros, and by looking at how the resulting C code is executed. 这页介绍了protothreads在这个hood下如何工作。我们来看看protothread C预处理宏如何工作,如何生成C代码被执行。 ? First, well introduce a simple example program written with protothreads. Since this is a simple program we can show the entire program, including the main() function from which the protothread is driven. The code, shown below, waits for a counter to reach a certain threshold, prints out a message, and resets the counter. This is done in a while() loop that runs forever. The counter is increased in the main() function. 首先,我们将介绍一个简单的用protothreads写的例子程序。由于这是一个简单的程序就可以显示整个程序,包括main()函数启动protothreads。代码如下所示,等待计数器达到一定的阈值就打印出一条消息,并重置计数器。这是在一

文档评论(0)

wt60063 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档