Preempt Rt例程
来源:互联网 发布:软件测试员工资怎么样 编辑:程序博客网 时间:2024/06/02 05:25
原文:https://wiki.linuxfoundation.org/realtime/documentation/howto/applications/application_base
/*$gcc -o thisfile thisfile.c -lpthread -lrt -Wall $sudo ./thisfile *//* * POSIX Real Time Example * using a single pthread as RT thread */#include <limits.h>#include <pthread.h>#include <sched.h>#include <stdio.h>#include <stdlib.h>#include <sys/mman.h>void *thread_func(void *data){ /* Do RT specific stuff here */ return NULL;}int main(int argc, char* argv[]){ struct sched_param param; pthread_attr_t attr; pthread_t thread; int ret; /* Lock memory */ if(mlockall(MCL_CURRENT|MCL_FUTURE) == -1) { printf("mlockall failed: %m\n"); exit(-2); } /* Initialize pthread attributes (default values) */ ret = pthread_attr_init(&attr); if (ret) { printf("init pthread attributes failed\n"); goto out; } /* Set a specific stack size */ ret = pthread_attr_setstacksize(&attr, PTHREAD_STACK_MIN); if (ret) { printf("pthread setstacksize failed\n"); goto out; } /* Set scheduler policy and priority of pthread */ ret = pthread_attr_setschedpolicy(&attr, SCHED_FIFO); if (ret) { printf("pthread setschedpolicy failed\n"); goto out; } param.sched_priority = 80; ret = pthread_attr_setschedparam(&attr, ¶m); if (ret) { printf("pthread setschedparam failed\n"); goto out; } /* Use scheduling parameters of attr */ ret = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); if (ret) { printf("pthread setinheritsched failed\n"); goto out; } /* Create a pthread with specified attributes */ ret = pthread_create(&thread, &attr, thread_func, NULL); if (ret) { printf("create pthread failed\n"); goto out; } /* Join the thread and wait until it is done */ ret = pthread_join(thread, NULL); if (ret) printf("join pthread failed: %m\n");out: return ret;}
阅读全文
0 0
- Preempt Rt例程
- Rt preempt Howto [dslab]
- preempt-RT patches
- rt preempt -- 编译实时内核
- Some questions about RT-preempt
- kernel build & preempt-rt patch & xenomai
- Linux优化-Preempt RT关键点
- 给Ubuntu 17.04打Preempt Rt补丁
- preempt
- ubuntu打实时内核补丁(RT-PREEMPT kernel)
- Linux RT(2)-硬实时Linux(RT-Preempt Patch)的中断线程化
- Linux RT(2)-硬实时Linux(RT-Preempt Patch)的中断线程化
- Linux RT(2)-硬实时Linux(RT-Preempt Patch)的中断线程化
- Linux RT(1)-硬实时Linux(RT-Preempt Patch)在PC上的编译、使用和测试
- Linux RT(1)-硬实时Linux(RT-Preempt Patch)在PC上的编译、使用和测试
- 硬实时Linux(RT-Preempt Patch)在PC上的编译、使用和测试
- Kernel Preempt
- preempt注释
- mysql group by组内排序
- web端跨页面传参
- Volley: [1141] BasicNetwork.performRequest: Unexpected response code 429 for https://xxxxxx.com/api/
- TaobaoSchedule调度管理控制台
- LeetCode 76. Minimum Window Substring
- Preempt Rt例程
- 第四周-单链表的的建立
- Windows下的Jupyter Notebook 安装与自定义启动
- 解决Android中No resource found that matches android:TextAppearance.Material.Widget.Button.Inverse问题
- Failed to resolve: 包名 解决方式
- 数据结构上机实践第四周项目6- 循环双链表应用
- 奥威Power-BI 生产制造BI解决方案——产品计划达成分析
- 第五周项目二
- WebStorm2017激活方法