contiki-断点的保存和恢复
保存断点
保存断点是通过保存行数来完成的,在被中断的地方插入编译器关键字_LINE_,编译器便自动记录所终端的行数。展开那些具有中断功能的宏,可以发现最后保存行数是宏LC_SET,取宏PROCESS_WAIT_EVENT()为例,将其展开得到如下代码:
- /**
- * Wait for an event to be posted to the process.
- *
- * This macro blocks the currently running process until the process
- * receives an event.
- *
- * \hideinitializer
- */
- #define PROCESS_WAIT_EVENT() PROCESS_YIELD()
- /**
- * Yield the currently running process.
- *
- * \hideinitializer
- */
- #define PROCESS_YIELD() PT_YIELD(process_pt)
- /**
- * Yield from the current protothread.
- *
- * This function will yield the protothread, thereby allowing other
- * processing to take place in the system.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \hideinitializer
- */
- #define PT_YIELD(pt) \
- do { \
- PT_YIELD_FLAG = ; \
- LC_SET((pt)->lc); \
- if(PT_YIELD_FLAG == ) { \
- return PT_YIELDED; \
- } \
- } while()
- //保存程序断点,下次再运行该进程直接跳到case __LINE__
- #define LC_SET(s) s = __LINE__; case __LINE__:
宏LC_SET展开还包含语句case _LINE_,用于下次恢复断点,即下次通过switch语句便可跳转到case的下一句。
恢复断点
被中断程序再次获得执行权时,便从该进程的函数执行体进入,按照Contiki的编程替换,函数体第一条语句是PROCESS_BEGIN()宏,该宏包含一条switch语句,用于跳转到上一次被中断的行,从而恢复执行,宏PROCESS_BEGIN()展开的源代码如下:
- /**
- * Define the beginning of a process.
- *
- * This macro defines the beginning of a process, and must always
- * appear in a PROCESS_THREAD() definition. The PROCESS_END() macro
- * must come at the end of the process.
- *
- * \hideinitializer
- */
- #define PROCESS_BEGIN() PT_BEGIN(process_pt)
- /**
- * Declare the start of a protothread inside the C function
- * implementing the protothread.
- *
- * This macro is used to declare the starting point of a
- * protothread. It should be placed at the start of the function in
- * which the protothread runs. All C statements above the PT_BEGIN()
- * invokation will be executed each time the protothread is scheduled.
- *
- * \param pt A pointer to the protothread control structure.
- *
- * \hideinitializer
- */
- #define PT_BEGIN(pt) { char PT_YIELD_FLAG = 1; if (PT_YIELD_FLAG) {;} LC_RESUME((pt)->lc)
- #define LC_RESUME(s) switch(s) { case 0:
- //switch语句跳转到被中断的行
contiki-断点的保存和恢复的更多相关文章
- Android Fragment使用(三) Activity, Fragment, WebView的状态保存和恢复
Android中的状态保存和恢复 Android中的状态保存和恢复, 包括Activity和Fragment以及其中View的状态处理. Activity的状态除了其中的View和Fragment的状 ...
- Android之Activity状态的保存和恢复
系统在某些情况下会调用onSaveInstanceState()和onRestoreInstanceState() 这两个方法来保存和恢复Activity的状态. 一句话:Activity在" ...
- Android课程---Activity中保存和恢复用户状态
onSaveInstanceState 保存 在暂停之后和保存之前调用 onRestoreInstanceState 恢复 再启动之后和显示之前调用 package com.example.chens ...
- Android中突发情况Activity数据的保存和恢复
Android中突发情况Activity数据的保存和恢复 写在前面:在我们的APP使用的过程中,总有可能出现各种手滑.被压在后台.甚至突然被杀死的情况.所以对APP中一些临时数据或关键持久型数据,就需 ...
- ios开发——实用技术篇&数据保存于恢复
数据保存于恢复 用户操作(输入数据)之后,应用程序退出并且终止之后,当用户再次打开应用的时候还是保持原来的状态 一:在storyBoard中设置恢复标志符 二:在AppDalegate中代理方法 -( ...
- Delphi语言怎样对自己定义类进行持久化保存及恢复 (性能远比json/xml高)
Delphi的RTL自身就带有一套非常好的资源持久化保存(IDE设计窗口时,保存为DFM格式及编译到EXE里面的资源文件)及恢复机制(EXE启动时对窗口资源的载入),那么应不是必需再额外用xml/js ...
- [翻译] Tensorflow模型的保存与恢复
翻译自:http://cv-tricks.com/tensorflow-tutorial/save-restore-tensorflow-models-quick-complete-tutorial/ ...
- 如何禁止App在后台运行以及如何保存和恢复App的状态
大熊猫猪·侯佩原创或翻译作品.欢迎转载,转载请注明出处. 如果觉得写的不好请多提意见,如果觉得不错请多多支持点赞.谢谢! hopy ;) 如果禁止App在后台运行 iOS上的App类似于Windows ...
- tensorflow 1.0 学习:模型的保存与恢复(Saver)
将训练好的模型参数保存起来,以便以后进行验证或测试,这是我们经常要做的事情.tf里面提供模型保存的是tf.train.Saver()模块. 模型保存,先要创建一个Saver对象:如 saver=tf. ...
- 第六节,TensorFlow编程基础案例-保存和恢复模型(中)
在我们使用TensorFlow的时候,有时候需要训练一个比较复杂的网络,比如后面的AlexNet,ResNet,GoogleNet等等,由于训练这些网络花费的时间比较长,因此我们需要保存模型的参数. ...
随机推荐
- js基础练习一之tab选项卡
最近在学习前端,当然包括js,css,html什么的,在听课时做的一些小练习,记录下来: 实例一: --Tab选项卡-- <script type="text/javascript&q ...
- yii2得到的数据对象转化成数组
yii2得到的数据对象转化成数组需要用到asArray().1.Customer::find(['id' => $id])->asArray()->one();2.$model = ...
- eclispe或者myeclispe maven jar包不能部署到tomcat下
我们在做web开发是,经常都要在eclipse或者myeclipse中搭建web服务器,并将开发中的web项目部署到web服务器进行调试,在此,我选择的是tomcat服务器.之前部署web项目到tom ...
- ES6里箭头函数的陷阱
ECMAScript 6新增了箭头函数 原来的匿名函数 function(){},现在可以简化成()=>{} 看起来高大上,像C#什么的语法. 但是箭头函数的this对象,不能更改,总是指向函数 ...
- js学习心得之思维逻辑与对象上下文环境(一)
html5 canvas矩形绘制实例(绘图有js 实现) html: <canvas id="myCanvas" width="200" height=& ...
- 无法打开物理文件xxx.mdf操作系统错误 5:“5(拒绝访问。)” (Microsoft SQL Server,错误: 5120)的解决方法
无法打开物理文件xxx.mdf操作系统错误 5:“5(拒绝访问.)” (Microsoft SQL Server,错误: 5120)的解决方法 问题描述: 在附加数据库到sql server时,附 ...
- Android 仿QQ消息界面
values 下面 dimens.xml <resources> <!-- Default screen margins, per the Android Design guidel ...
- IBM WebSphere MQ的oracle的jdbc
一.IBM WebSphere MQ7.0的jdbc支持数据库有: DB2 Informix Informix_With_Date_Format Microsoft_SQL_Server Oracle ...
- android控件的对齐方式(转)
<?xml version="1.0" encoding="utf-8"?> <!-- android:layout_above 将该控件的底 ...
- base64与byte[]之间转换
主要是根据BASE64Encoder 和BASE64Decoder 进行操作实现,具体例子如下: BASE64Encoder encode = new BASE64Encoder(); //将byte ...