第20章-51系列單片機的多任務(wù)操作系統(tǒng)+.ppt_第1頁
第20章-51系列單片機的多任務(wù)操作系統(tǒng)+.ppt_第2頁
第20章-51系列單片機的多任務(wù)操作系統(tǒng)+.ppt_第3頁
第20章-51系列單片機的多任務(wù)操作系統(tǒng)+.ppt_第4頁
第20章-51系列單片機的多任務(wù)操作系統(tǒng)+.ppt_第5頁
已閱讀5頁,還剩10頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請進(jìn)行舉報或認(rèn)領(lǐng)

文檔簡介

1、21天學(xué)51單片機開發(fā),第二十講:51系列單片機的多任務(wù)操作系統(tǒng),課程安排,RTX-51實時多任務(wù)操作系統(tǒng)簡介 RTX-51 Tiny的任務(wù)管理 RTX-51 Tiny的系統(tǒng)函數(shù) RTX-51與單任務(wù)程序的比較 RTX-51循環(huán)任務(wù)調(diào)度程序設(shè)計 RTX-51事件任務(wù)調(diào)度程序設(shè)計 RTX-51信號任務(wù)調(diào)度程序設(shè)計 RTX-51優(yōu)先級及搶先任務(wù)切換程序設(shè)計,RTX-51實時多任務(wù)操作系統(tǒng)簡介,多任務(wù)操作系統(tǒng)也就是可以運行多個程序的平臺。 RTX-51是一種適用于51系列單片機的實時多任務(wù)操作系統(tǒng)(RTOS)。 RTX-51實時多任務(wù)系統(tǒng) RTX-51 FULL RTX-51 Tiny,RTX-51

2、實時多任務(wù)系統(tǒng)特點,任務(wù)調(diào)度 信息傳遞 中斷 CAN通信 BITBUS通信,RTX-51 Tiny的任務(wù)管理,在RTX-51 Tiny中支持5種任務(wù)狀態(tài),任何一個任務(wù)必須處于其中一個確定的狀態(tài)。 READY RUNING WAITING DELETED TIMEOUT,RTX-51 Tiny支持的事件,信號(SIGNAL) 超時(TIMEOUT) 時間間隔事件(INTERVAL),RTX-51 Tiny的系統(tǒng)函數(shù),信號發(fā)送函數(shù)isr_send_signal 信號標(biāo)志清除函數(shù)os_clear_signal 任務(wù)啟動函數(shù)os_create_task 任務(wù)刪除函數(shù)os_delete_task 當(dāng)前任

3、務(wù)號函數(shù)os_running_task_id 信號發(fā)送函數(shù)os_send_signal 等待函數(shù)os_wait 等待函數(shù)os_wait1 等待函數(shù)os_wait2,RTX-51與單任務(wù)程序的比較,簡單的單任務(wù)C51程序,01#include 02#include 03int count=0; 04void main()/主函數(shù) 05 06while(1)/主循環(huán) 07 08count+;/計數(shù)器加1 09printf(Single Task: count=%d,count);/輸出 10if(count=500) 11 12count=0;/歸零 13 14 15,RTX-51與單任務(wù)程序的比

4、較,多任務(wù)循環(huán)C51程序,01#include 02#include 03int count0=0; 04int count1=0; 05void main()/主函數(shù) 06 07while(1)/主循環(huán) 08 09count0+;/計數(shù)器count0加1 10printf(Single Process Task0:count0=%dn,count0); 11count1+;/計數(shù)器count1加1 12printf(Single Process Task1:count1=%dn,count1); 13if(count0=500) 14 15count0=0; 16 17if(count1=5

5、00) 18 19count1=0; 20 21 22,RTX-51與單任務(wù)程序的比較,多任務(wù)RTX-51程序,01#include 02#include 03#include 04int count0=0; 05int count1=0; 06Thread0 () _task_ 0 /任務(wù)0 07 08os_create_task(1);/創(chuàng)建任務(wù)1 09while(1) 10 11printf(Task0:count0=%dn,count0+); /打印輸出count0 12if(count0=500) 13 14count0=0; 15 16 17 18Thread1 () _task_

6、 1 /任務(wù)1 19 20while(1) 21 22printf(Task1:count1=%dn,count1+);/打印輸出count1 23if(count1=500) 24 25count1=0; 26 27 28,RTX-51循環(huán)任務(wù)調(diào)度程序設(shè)計,RTX-51循環(huán)任務(wù)調(diào)度是按照預(yù)先劃分的時間片來循環(huán)輪流執(zhí)行多個任務(wù)的。,01#include 02#include 03#include 04Thread0 () _task_ 0 /任務(wù)0 05 06P1=0 x00;/初始化 07P2=0 x00; 08os_create_task(1);/創(chuàng)建任務(wù)1 09while(1) 10 1

7、1P1=P1+1;/P1端口遞增 12 13 14Thread1 () _task_ 1 /任務(wù)1 15 16while(1) 17 18P2=P2+1;/P2端口遞增 19 20,RTX-51事件任務(wù)調(diào)度程序設(shè)計,RTX-51事件任務(wù)調(diào)度是使用事件來實現(xiàn)多任務(wù)之間切換的調(diào)度方式。,01#include 02#include 03#include 04int count0=0; 05int count1=0; 06Thread0 () _task_ 0 /任務(wù)0 07 08os_create_task(1); /創(chuàng)建任務(wù)1 09while(1) 10 11printf(Task0:count0

8、=%dn,count0+);/打印輸出count0 12os_wait(K_TMO,2);/暫停兩個信號 13if(count0=500) 14 15count0=0; 16 17 18 19Thread1 () _task_ 1 /任務(wù)1 20 21while(1) 22 23printf(Task1:count1=%dn,count1+);/打印輸出count1 24os_wait(K_TMO,3);/暫停三個信號 25if(count1=500) 26 27count1=0; 28 29 30,RTX-51信號任務(wù)調(diào)度程序設(shè)計,RTX-51信號任務(wù)調(diào)度是使用信號來完成多任務(wù)之間切換的調(diào)度

9、方式。,01#include 02#include 03#include 04int count0=0; 05int count1=0; 06Thread0 () _task_ 0 /任務(wù)0 07 08os_create_task(1); /創(chuàng)建任務(wù)1 09while(1) 10 11printf(Task0:count0=%dn,count0+); /打印輸出count0 12if(count0=10) 13 14os_send_signal(1);/向任務(wù)1發(fā)送信號 15count0=0; 16 17 18 19Thread1 () _task_ 1 /任務(wù)1 20 21while(1)

10、22 23os_wait(K_SIG,0,0);/等待信號 24printf(Task1:count1=%dn,count1+);/打印輸出count1 25 26,RTX-51優(yōu)先級及搶先任務(wù)切換程序設(shè)計,搶先任務(wù)切換是根據(jù)不同任務(wù)的優(yōu)先級來執(zhí)行不同任務(wù)的調(diào)度方式。,01#include 02#include 03#include 04int count0=0; 05int count1=0; 06Thread0 () _task_ 0 /任務(wù)0 07 08os_create_task(1); /創(chuàng)建任務(wù)1 09while(1) 10 11printf(Task0:count0=%dn,count0+); /打印輸出count0 12if(count0=10) 13 14os_send_signal(1);/向任務(wù)1發(fā)送信號 15count0=0; 16 1

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時也不承擔(dān)用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論