资源描述:
《ctgu嵌入式-μcos-ii-实验6-时钟中断》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、姓名:张定水学号:2013112134实验6时钟中断实验内容:(一般包含以下几个方面)实验的内容以及要求1)总本空鉛中,谄诂3三个点务Task1、Task2、Task3,创建3—个<8%$InterruptSemo2)整个養俊的迄紂洼終厶下:3)爺俊初能亿,TaskStart存务中,钊建并总莎&务Taskl、Task2、Task3,优兔假分别弟12,13,14。4)dTaskStart<4务申钊建一个传%-fInterruptSem(初価筠1)。5)<4#^TaskStart&勞中3圭超匂乙,湧仔桑俊空施讷虐,(2入Taskl迄
2、$;6)伍多Task1瞇旅lOOticks;7)伍务Task2科壮城&,&务Task2%InterruptSem;8)伍务Task2oi^50()tick,伍务Task3雄入迄&,幻印篩出语旬后迄时,伍發Task1瞇服时向到僞谨雄入迄$,它申洁传禺蚤InterruptSem失敗被阻塞;9)传务Task3雄入迄&,馮环他幻印雄出倨旬。期向时狒中新不断戶隹,巻中新红理終瘵申対传务Task2的睡旅时向(2$■诂数;10)Task2睡服时向到后俊.連迄紂,并释长传备蚤InterruptSem;11)Taskl-%InterruptSem
3、后抢gTask2迄&;12)Task1磁用支传君蚤IntciTuptScm舄释孜遂传君逻;13)養侥从步黠4重夏如紂,一盍迄f孑下去……算法设计以及必要步骤程序代親Q下:voidTaskl(void*pdata){INT8Uerr;pdata=pdata;for(;;){OSTimeDly(lOO);printf("Task_ltryingtogetsemaphore.r");/*taskldelay100clockticks*/OSSemPend(lnterruptSem,0,&err);/*Acquiresemapho
4、retogetintotheroom*/printf("Task_lGOTsemaphore,thedelay...r");OSTimeDly(200);printf("Task_ldelaytimeout!r");printf("Task_lRELEASEsemaphore.r");OSSemPostflnterruptSem);/*Releasesemaphore*/}}voidTask2(void*pdata){INT8Uerr;pdata=pdata;for(;;){OSTimeDly(lOO);pri
5、ntf("Task_2tryingtogetsemaphore.r");/*taskldelay100clockticks*/OSSemPend(InterruptSem,0,&err);/*Acquiresemaphoretogetintotheroom*/printf("Task_2GOTsemaphore,thedelay...r");OSTimeDly(500);printf("Task_2delaytimeout!r");printf("Task_2RELEASEsemaphore.rM);OS
6、SemPost(lnterruptSem);/*Releasesemaphore*/}}voidTask3(void*pdata){pdata=pdata;for(;;){printf("tTask_3gotCPU,andrunning......!r");OSTimeDly(lOO);}}代码见文件init.c运行结果(拷屏)gotgotgotgotCPU,andCPU,andCPU,andCPU,andrunningrunningrunningrunningTask_3Task_3Task_3Task_3Task.Z
7、delaytimeout?T1得至【I住吕量Task.2RELEASEsemaphore.:丄;寸:t」I口P車Task_lGOTsemaphore,thedelay...delay200running.running.running.running.running.fTask_2tryingtog^tsemaphore・running.running.running.running.running.Task_3Task_3Task_3Task_3Task3gotgotgotgotgotCPU,andCPU,andCPU,and
8、CPU,andCPU,andTask_3Task_3Task_3Task_3Task_3gotCPU,andgotgotgotgotCPU,andCPU,andCPU^andCPU,andTask_ldelaytim巳out?Task_lRELEASEsemap