当前位置: 首页 > news >正文

附近企业建站公司做书籍封皮的网站

附近企业建站公司,做书籍封皮的网站,长春工程建设信息网站,网站是用php还是asp 怎么区别一.任务状态理论讲解 正在执行的任务状态是running#xff0c;其他执行的等待执行的任务状态是ready 1.修改间隔时间 2.任务状态 处于各个状态的任务是怎样被管理起来的#xff1a;链表 3.代码 TaskHandle_t xHandleTask1; TaskHandle_t xHandleTask3;static int task1f…一.任务状态理论讲解 正在执行的任务状态是running其他执行的等待执行的任务状态是ready  1.修改间隔时间 2.任务状态  处于各个状态的任务是怎样被管理起来的链表  3.代码 TaskHandle_t xHandleTask1; TaskHandle_t xHandleTask3;static int task1flagrun 0; static int task2flagrun 0; static int task3flagrun 0;void Task1Function(void * param) {TickType_t tStart xTaskGetTickCount();TickType_t t;int flag 0;while (1){t xTaskGetTickCount();task1flagrun 1;task2flagrun 0;task3flagrun 0;printf(1);if (!flag (t tStart 10)){vTaskSuspend(xHandleTask3);flag 1;}if (t tStart 20){vTaskResume(xHandleTask3);}} }void Task2Function(void * param) {while (1){task1flagrun 0;task2flagrun 1;task3flagrun 0;printf(2);vTaskDelay(10);} }void Task3Function(void * param) {while (1){task1flagrun 0;task2flagrun 0; task3flagrun 1;printf(3);} }/*-----------------------------------------------------------*/StackType_t xTask3Stack[100]; StaticTask_t xTask3TCB;StackType_t xIdleTaskStack[100]; StaticTask_t xIdleTaskTCB;/** The buffers used here have been successfully allocated before (global variables)*/ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,StackType_t ** ppxIdleTaskStackBuffer,uint32_t * pulIdleTaskStackSize ) {*ppxIdleTaskTCBBuffer xIdleTaskTCB;*ppxIdleTaskStackBuffer xIdleTaskStack;*pulIdleTaskStackSize 100; }int main( void ) {#ifdef DEBUGdebug(); #endifprvSetupHardware();printf(Hello, world!\r\n);xTaskCreate(Task1Function, Task1, 100, NULL, 1, xHandleTask1);xTaskCreate(Task2Function, Task2, 100, NULL, 1, NULL);xHandleTask3 xTaskCreateStatic(Task3Function, Task3, 100, NULL, 1, xTask3Stack, xTask3TCB);/* Start the scheduler. */vTaskStartScheduler();/* Will only get here if there was not enough heap space to create theidle task. */return 0; } 二.vTaskDelay和vTaskDelayUntil vTaskDelay至少等待指定个数的Tick Interrupt才能变为就绪状态 xTaskDelayUntil 返回pdTRUE表示确实延迟了返回pdFALSE表示没有发生延迟(因为延迟的时间点早就过了) 等待到指定的绝对时刻才能变为就绪态。 代码1 vTaskDelay TaskHandle_t xHandleTask1; TaskHandle_t xHandleTask3;static int task1flagrun 0; static int task2flagrun 0; static int task3flagrun 0;static int rands[]{3,56,23,5,59};void Task1Function(void * param) {TickType_t tStart xTaskGetTickCount();int i0;int j0;while (1){ task1flagrun 1;task2flagrun 0;task3flagrun 0;for( i 0; i rands[j] ; i)printf(1);j;if ( j 5)j 0;vTaskDelay(20);} }void Task2Function(void * param) {while (1){task1flagrun 0;task2flagrun 1;task3flagrun 0;printf(2);} }void Task3Function(void * param) {while (1){task1flagrun 0;task2flagrun 0; task3flagrun 1;printf(3);} }/*-----------------------------------------------------------*/StackType_t xTask3Stack[100]; StaticTask_t xTask3TCB;StackType_t xIdleTaskStack[100]; StaticTask_t xIdleTaskTCB;/** The buffers used here have been successfully allocated before (global variables)*/ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,StackType_t ** ppxIdleTaskStackBuffer,uint32_t * pulIdleTaskStackSize ) {*ppxIdleTaskTCBBuffer xIdleTaskTCB;*ppxIdleTaskStackBuffer xIdleTaskStack;*pulIdleTaskStackSize 100; }int main( void ) {#ifdef DEBUGdebug(); #endifprvSetupHardware();printf(Hello, world!\r\n);xTaskCreate(Task1Function, Task1, 100, NULL, 2, xHandleTask1);xTaskCreate(Task2Function, Task2, 100, NULL, 1, NULL);xHandleTask3 xTaskCreateStatic(Task3Function, Task3, 100, NULL, 1, xTask3Stack, xTask3TCB);/* Start the scheduler. */vTaskStartScheduler();/* Will only get here if there was not enough heap space to create theidle task. */return 0; } 可以看到任务1执行的时间不一样但是进入delay休眠的时间是一样的都是20ms。 代码2 vTaskDelayUntil BaseType_t xTaskDelayUntil( TickType_t * const pxPreviousWakeTime,const TickType_t xTimeIncrement ) ; // 1 延迟直到 *pxPrexTime // 2 *pxPre*pxPrexTime TaskHandle_t xHandleTask1; TaskHandle_t xHandleTask3;static int task1flagrun 0; static int task2flagrun 0; static int task3flagrun 0;static int rands[]{3,56,23,5,59};void Task1Function(void * param) {TickType_t tStart xTaskGetTickCount();int i0;int j0;while (1){ task1flagrun 1;task2flagrun 0;task3flagrun 0;for( i 0; i rands[j] ; i)printf(1);j;if ( j 5)j 0; #if 0vTaskDelay(20); #elsexTaskDelayUntil(tStart,20); #endif} }void Task2Function(void * param) {while (1){task1flagrun 0;task2flagrun 1;task3flagrun 0;printf(2);} }void Task3Function(void * param) {while (1){task1flagrun 0;task2flagrun 0; task3flagrun 1;printf(3);} }/*-----------------------------------------------------------*/StackType_t xTask3Stack[100]; StaticTask_t xTask3TCB;StackType_t xIdleTaskStack[100]; StaticTask_t xIdleTaskTCB;/** The buffers used here have been successfully allocated before (global variables)*/ void vApplicationGetIdleTaskMemory( StaticTask_t ** ppxIdleTaskTCBBuffer,StackType_t ** ppxIdleTaskStackBuffer,uint32_t * pulIdleTaskStackSize ) {*ppxIdleTaskTCBBuffer xIdleTaskTCB;*ppxIdleTaskStackBuffer xIdleTaskStack;*pulIdleTaskStackSize 100; }int main( void ) {#ifdef DEBUGdebug(); #endifprvSetupHardware();printf(Hello, world!\r\n);xTaskCreate(Task1Function, Task1, 100, NULL, 2, xHandleTask1);xTaskCreate(Task2Function, Task2, 100, NULL, 1, NULL);xHandleTask3 xTaskCreateStatic(Task3Function, Task3, 100, NULL, 1, xTask3Stack, xTask3TCB);/* Start the scheduler. */vTaskStartScheduler();/* Will only get here if there was not enough heap space to create theidle task. */return 0; } 以每20ms周期性的执行  三.空闲任务及钩子函数  实验1 执行任务1任务1的任务是创建任务2当任务2创建成功任务2的优先级更高直接执行任务2。任务2的任务是打印一个2然后进入阻塞任务1运行删除任务。 extern void Task2Function(void * param);void Task1Function(void * param) {TaskHandle_t xHandleTask2;BaseType_t xReturn;while (1){printf(1);xReturnxTaskCreate(Task2Function, Task2, 1024, NULL, 2, xHandleTask2);if(xReturn!pdPASS){printf(xTaskCreate err\r\n);}vTaskDelete(xHandleTask2);} }void Task2Function(void * param) {while (1){printf(2);vTaskDelay(2);} }/*-----------------------------------------------------------*/int main( void ) {TaskHandle_t xHandleTask1;#ifdef DEBUGdebug(); #endifprvSetupHardware();printf(Hello, world!\r\n);xTaskCreate(Task1Function, Task1, 100, NULL, 1, xHandleTask1);/* Start the scheduler. */vTaskStartScheduler();/* Will only get here if there was not enough heap space to create theidle task. */return 0; } 并没有执行我们想要的清理工作。 我们进行的清理工作(内存回收工作)是放在空闲任务里面的。 实验2  执行自杀操作 extern void Task2Function(void * param);void Task1Function(void * param) {TaskHandle_t xHandleTask2;BaseType_t xReturn;while (1){printf(1);xReturnxTaskCreate(Task2Function, Task2, 1024, NULL, 2, xHandleTask2);if(xReturn!pdPASS){printf(xTaskCreate err\r\n);}//vTaskDelete(xHandleTask2);} }void Task2Function(void * param) {while (1){printf(2);vTaskDelay(2);vTaskDelete(NULL);//执行自杀操作} }/*-----------------------------------------------------------*/int main( void ) {TaskHandle_t xHandleTask1;#ifdef DEBUGdebug(); #endifprvSetupHardware();printf(Hello, world!\r\n);xTaskCreate(Task1Function, Task1, 100, NULL, 1, xHandleTask1);/* Start the scheduler. */vTaskStartScheduler();/* Will only get here if there was not enough heap space to create theidle task. */return 0; } 执行自杀操作应该由空闲任务帮你执行清理工作 配置钩子函数 在main函数里面创建任务1优先级是0任务1里面创建任务2任务2优先级更高执行完之后就自杀。之后任务1和任务0可以交替执行 四.任务调度算法 static int task1flagrun 0; static int task2flagrun 0; static int task3flagrun 0; static int taskidleflagrun 0;void Task1Function(void * param) {//volatile char buf[500];//int i;while (1){task1flagrun 1;task2flagrun 0;task3flagrun 0;taskidleflagrun 0;printf(1);} }void Task2Function(void * param) {int i 0;while (1){task1flagrun 0;task2flagrun 1;task3flagrun 0;taskidleflagrun 0;printf(2);} }void Task3Function(void * param) {const TickType_t xDelay5mspdMS_TO_TICKS(5UL);while (1){task1flagrun 0;task2flagrun 0; task3flagrun 1;taskidleflagrun0;printf(3);//如果不休眠的化其他任务无法得到执行vTaskDelay(xDelay5ms);} }void vApplicationIdleHook() {task1flagrun 0;task2flagrun 0; task3flagrun 0;taskidleflagrun1; }int main( void ) {#ifdef DEBUGdebug(); #endifprvSetupHardware();printf(Hello, world!\r\n);xTaskCreate(Task1Function, Task1, 1000, NULL, 0, NULL);xTaskCreate(Task2Function, Task2, 1000, NULL, 0, NULL);xTaskCreate(Task3Function, Task3, 1000, NULL, 2, NULL);//优先级最高的任务3先执行/* Start the scheduler. */vTaskStartScheduler();/* Will only get here if there was not enough heap space to create theidle task. */return 0; } 1.可以抢占 这个宏定义是否可以抢占 任务3优先级最高先执行执行完阻塞5ms其他任务执行。执行任务1任务2任务1任务2任务0任务1。5ms到了立刻执行任务3... A.时间片轮转 任务3优先级最高先执行执行完阻塞5ms其他任务执行。执行任务1任务2任务1任务2任务0任务1。5ms到了立刻执行任务3... B.时间片不轮转 任务3优先级最高先执行执行完进入休眠任务1执行直到任务3休眠结束任务3执行结束就接着让任务2执行.... 2.不可以抢占 任务3执行完了进入阻塞任务1一直执行。如果需要让出CPU资源还是需要自己去主动进入休眠。  3.空闲任务是否让步于用户任务
http://icebutterfly214.com/news/23383/

相关文章:

  • powerGrid靶机复盘WP
  • 2025 年 11 月财税合规服务厂家推荐排行榜,电商/跨境电商/出口退税/公司注销/股权设计/平台报送/海外公司/审计报告全案解决方案
  • 2025 年 11 月疥螨阴虱药剂厂家推荐排行榜,扑灭司林/5%扑灭司林,苯甲酸苄酯/25%苯甲酸苄酯,15%胺氯菊百灭宁,科灭达公司推荐
  • Vibe Coding - 免费使用gpt-5、grok-code-fast-1进行氛围编程
  • 大家好
  • 前端框架深度解析:Vue 从入门到实战,掌握渐进式开发核心 - 实践
  • 浅谈dp中的最优化、计数问题
  • 2025北京一对一辅导/补习/培训/家教/网课推荐榜:金博教育领衔,3家优质机构凭个性化服务出圈,适配多元学习需求
  • CF1463E Plan of Lectures
  • 251107
  • P3978 概率论
  • 2025-11-07 PQ v.Next日志记录
  • 2025-11-07 早报新闻
  • R语言实现多组样本两两t检验的完整教程
  • SDOI 2024游记兼退役游记
  • NOIP 模拟赛 3 比赛总结
  • 2025年TWS耳机磁铁厂家权威推荐榜单:手机磁铁/钕铁硼磁铁/稀土磁铁源头厂家精选
  • 2025 年 11 月深圳店铺装修公司推荐排行榜,餐饮店铺装修,商场店铺装修,连锁店铺装修,零售店铺装修设计公司推荐
  • 护手仪ESD整改-ASIM阿赛姆
  • 2025年市面上成都小程序机构top10推荐:杰诚智享领跑行业
  • 气氛
  • 2025年热门成人自考机构推荐
  • 小 E 的传奇一生
  • 2025 年 11 月全自动加袋机厂家推荐排行榜,FFS/25公斤/吨袋/吨包全自动上袋机,肥料/铜精粉全自动吨袋上袋机,无锡江苏全自动吨包上袋机公司推荐
  • 2025 年 11 月包装称厂家推荐排行榜,全自动/定量/FFS重膜/高速/锂电/零排放/螺旋/吨袋包装称,铜精粉/肥料吨包包装称公司精选
  • 2025 年 11 月潜水泵厂家推荐排行榜,新型潜水泵,节能潜水泵,低噪声潜水泵,超低压潜水泵,防爆潜水泵,高压潜水泵,防腐潜水泵,SF潜水泵,SFB潜水泵,WF屋顶潜水泵公司推荐
  • git 添加大文件
  • OIFC 2025.11.7 模拟赛总结
  • 2025年背封湿巾包装机生产厂家权威推荐榜单:棉片湿巾包装机/航空湿巾包装机/一次性湿巾包装源头厂家精选
  • 2025 年防静电地板源头厂家最新推荐榜单:权威品牌实力展现及选购指南生产防静电地板/防静电活动地板/抗静电地板公司推荐