- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
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。代码如下所示,等待计数器达到一定的阈值就打印出一条消息,并重置计数器。这是在一
您可能关注的文档
最近下载
- 电力隧道电力隧道工程c标段施工方案.doc VIP
- 九年级物理第21章《信息的传递》全章课件.ppt VIP
- Unit 4 Fun with numbers(Get ready)外研版(三起)(2024)英语三年级上册.pptx VIP
- (妇产科)子宫内膜癌教学查房.pptx
- 供应商审核报告范文模板.docx VIP
- 机场行测考试题库.pdf VIP
- 2025年《网络设备配置与安全》课程标准.docx VIP
- 成都市盐道街中学高一入学语文分班考试真题含答案.docx VIP
- 成都市盐道街外国语2025高一入学英语分班考试真题含答案.docx VIP
- 成都市盐道街外国语2025高一入学数学分班考试真题含答案.docx VIP
文档评论(0)