linux - native task api 测试
#include <stdio.h>
#include <signal.h>
#include <unistd.h>
#include <sys/mman.h>
#include <native/task.h>
#include <native/timer.h>
RT_TASK demo_task;
/* NOTE: error handling omitted. */
void demo(void *arg)
{
RTIME now, previous;
/*
* Arguments: &task (NULL=self),
* start time,
* period (here: 1 ms)
*/
rt_task_set_periodic(NULL, TM_NOW, 1000000);
previous = rt_timer_read();
while (1) {
rt_task_wait_period(NULL);
now = rt_timer_read();
/*
* NOTE: printf may have unexpected impact on the timing of
* your program. It is used here in the critical loop
* only for demonstration purposes.
*/
printf("Time since last turn: %ld.%06ld ms\n",
(long)(now - previous) / 1000000,
(long)(now - previous) % 1000000);
previous = now;
}
}
void catch_signal(int sig)
{
}
int main(int argc, char* argv[])
{
signal(SIGTERM, catch_signal);
signal(SIGINT, catch_signal);
/* Avoids memory swapping for this program */
mlockall(MCL_CURRENT|MCL_FUTURE);
/*
* Arguments: &task,
* name,
* stack size (0=default),
* priority,
* mode (FPU, start suspended, ...)
*/
rt_task_create(&demo_task, "trivial", 0, 99, 0);
/*
* Arguments: &task,
* task function,
* function argument
*/
rt_task_start(&demo_task, &demo, NULL);
pause();
rt_task_delete(&demo_task);
return 0;
}
2 测试结果:
Time since last turn: 0.997940 ms
Time since last turn: 1.001939 ms
Time since last turn: 0.996909 ms
Time since last turn: 1.000727 ms
Time since last turn: 1.003576 ms
Time since last turn: 1.000606 ms
Time since last turn: 0.998909 ms
Time since last turn: 0.998243 ms
Time since last turn: 1.001333 ms
Time since last turn: 0.997636 ms
Time since last turn: 1.003152 ms
Time since last turn: 0.996788 ms
Time since last turn: 1.000060 ms
Time since last turn: 0.998667 ms
Time since last turn: 1.005030 ms
Time since last turn: 0.995031 ms
Time since last turn: 1.002545 ms
Time since last turn: 1.002303 ms
Time since last turn: 0.995515 ms
Time since last turn: 1.002849 ms
Time since last turn: 0.997878 ms
Time since last turn: 1.002000 ms
Time since last turn: 0.998546 ms
Time since last turn: 0.999576 ms
Time since last turn: 1.002363 ms
Time since last turn: 0.998425 ms
Time since last turn: 0.998969 ms
Time since last turn: 1.000061 ms
Time since last turn: 1.002788 ms
Time since last turn: 0.996848 ms
Time since last turn: 1.002182 ms
Time since last turn: 0.999212 ms
Time since last turn: 1.001455 ms
Time since last turn: 0.997636 ms
Time since last turn: 1.004546 ms
Time since last turn: 0.995757 ms
Time since last turn: 1.000788 ms
Time since last turn: 0.998485 ms
Time since last turn: 1.001333 ms
Time since last turn: 0.998485 ms
Time since last turn: 1.001152 ms
Time since last turn: 0.999878 ms
Time since last turn: 0.999334 ms
Time since last turn: 1.002121 ms
Time since last turn: 0.999697 ms
Time since last turn: 1.000242 ms
Time since last turn: 0.997697 ms
Time since last turn: 1.000303 ms
Time since last turn: 0.999879 ms
Time since last turn: 1.000788 ms
Time since last turn: 1.000061 ms
Time since last turn: 0.999636 ms
Time since last turn: 1.001454 ms
Time since last turn: 0.997334 ms
Time since last turn: 1.004666 ms
Time since last turn: 0.996910 ms
Time since last turn: 1.002545 ms
Time since last turn: 0.996485 ms
Time since last turn: 1.001273 ms
Time since last turn: 0.998666 ms
Time since last turn: 1.000788 ms
Time since last turn: 0.999758 ms
Time since last turn: 1.000242 ms
Time since last turn: 0.999091 ms
Time since last turn: 1.002909 ms
Time since last turn: 1.000485 ms
Time since last turn: 0.996424 ms
Time since last turn: 1.001818 ms
linux - native task api 测试的更多相关文章
- API 测试的具体实现
目录 API 测试的具体实现 基于 Spring Boot 构建的 API 使用 cURL 命令行工具进行测试 使用图形界面工具 Postman 进行测试 如何应对复杂场景的 API 测试? 总结 A ...
- node-webkit学习(4)Native UI API 之window
node-webkit学习(4)Native UI API 之window 文/玄魂 目录 node-webkit学习(4)Native UI API 之window 前言 4.1 window a ...
- Java JVM、JNI、Native Function Interface、Create New Process Native Function API Analysis
目录 . JAVA JVM . Java JNI: Java Native Interface . Java Create New Process Native Function API Analys ...
- Linux Native Aio 异步AIO的研究
Linux Native Aio 异步AIO的研究 http://rango.swoole.com/archives/282 首先声明一下epoll+nonblock从宏观角度可以叫做全异步,但从微观 ...
- node-webkit教程<>Native UI API 之Menu(菜单)
node-webkit教程(6)Native UI API 之Menu(菜单)1 前言... 2 6.1 Menu 概述... 3 6.2 menu api6 6.2.1 new Menu([o ...
- API测试工具SoapUI & Postman对比分析
本文由葡萄城技术团队于博客园原创并首发 转载请注明出处:葡萄城官网,葡萄城为开发者提供专业的开发工具.解决方案和服务,赋能开发者. 最近公司要引入API测试工具,经过调查和了解,最终决定在SoapUI ...
- NODE-WEBKIT教程(6)NATIVE UI API 之MENU(菜单)
node-webkit教程(6)Native UI API 之Menu(菜单) 文/玄魂 目录 node-webkit教程(6)Native UI API 之Menu(菜单) 前言 6.1 Menu ...
- NODE-WEBKIT教程(5)NATIVE UI API 之FRAMELESS WINDOW
node-webkit教程(5)Native UI API 之Frameless window 文/玄魂 原文链接:http://www.xuanhun521.com/Blog/2014/4/15/n ...
- 如何选择API测试工具
没有最好,只有最合适. 如今,越来越多的公司正在向DevOps的方向左转,以实现持续集成和持续部署开发.这意味着我们的反馈需要比以往更快,以便确定我们的应用程序是否准备好交付.这就是API测试如此重要 ...
随机推荐
- windows获取本机MAC地址并写入文件的bat
windows获取本机MAC地址并写入文件的bat MAC(Media Access Control)地址,或称为 MAC地址.硬件地址,用来定义网络设备的位置. bat代码例如以下: @echo o ...
- C++ 11 - STL - 函数对象(Function Object) (下)
1. 预定义函数对象 C++标准库内含许多预定义的函数对象,也就是内置的函数对象. 你可以充分利用他们,不必自己费心去写一些自己的函数对象. 要使用他们,你只要包含如下头文件 #include < ...
- NGUI Tutorial 4 ScrollView
一.createScrollView 1.First, select the panel you want to be your scroll view and right-click anywher ...
- ES6 class 基本使用
<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...
- sql删除数据库所有表
use 数据库名(是要删除表的所在的那个数据库的名称) GO ) begin SELECT @sql='drop table ' + name FROM sysobjects WHERE (type ...
- 转:Socket常用选项
功能描述 获取或者设置与某个套接字关联的选 项.选项可能存在于多层协议中,它们总会出现在最上面的套接字层.当操作套接字选项时,选项位于的层和选项的名称必须给出.为了操作套接字层的选项,应该 将层的值指 ...
- Servlet/Jsp实现购物车
(1)用servlet实现简单的购物车系统,项目结构例如以下:(新建web Project项目 仅仅须要AddItemServlet , ListItemServlet.exam403.jsp三个文 ...
- .Net 两大利器Newtonsoft.NET和Dapper
你可以使用ado.net返回的DataTable让Newtonsoft.NET来序列化成Json. 当然你可以使用Dapper返回的List让Newtonsoft.NET来序列化成JSON. 参考资料 ...
- 创建你的第一个Android PHP应用
google的开源移动操作系统Android给智能手机市场带来了风暴.不像Apple,对想要为水果市场(Iphone App Store)提供应用软件的开发者们有着严格的指导原则以及要求,Google ...
- Dapper 中使用sql in 关键字查询
传统 sql in 写法是 SELECT * FROM dbo.Users s WHERE s.id IN (1,2,3) 在dapper因为安全性,不能直接用sql接接 要采用参数化, 开始我 ...