外文翻譯--RTX-51實時操作系統(tǒng)_第1頁
外文翻譯--RTX-51實時操作系統(tǒng)_第2頁
外文翻譯--RTX-51實時操作系統(tǒng)_第3頁
外文翻譯--RTX-51實時操作系統(tǒng)_第4頁
外文翻譯--RTX-51實時操作系統(tǒng)_第5頁
已閱讀5頁,還剩18頁未讀 繼續(xù)免費閱讀

付費下載

下載本文檔

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

文檔簡介

中文 4460 字 畢業(yè)設(shè)計 (論文 )外文資料翻譯 嵌入式實時操作系統(tǒng) RTX-51 的研究 學(xué) 生 姓 名: 班 級: 電自 047 學(xué) 號: 指 導(dǎo) 教 師: 所 在 單 位: 答 辯 日 期: 2008年 6 月 23日 1 附件 1:外文資料翻譯譯文 RTX-51 實時操作系統(tǒng) RTX51是一個適用于 8051 家族的實時多任務(wù)操作系統(tǒng)。 RTX51使復(fù)雜的系統(tǒng)和軟件設(shè)計以及有時間限制的工程開發(fā)變得簡單。 RTX51是一個強大的工具,它可以在 單個 CPU上管理幾個作業(yè)(任務(wù))。 RTX51有兩種不同的版本: RTX51 Full 允許 4個優(yōu)先權(quán)任務(wù)的循環(huán)和切換,并且還能并行的利用中斷功能。 RTX51支持信號傳遞,以及與系統(tǒng)郵箱和信號量進行消 息 傳遞。 RTX51的os_wait 函數(shù) 可以 等待 以 下事 件 : 中斷 、 時間 到、來自 任務(wù) 或 中斷的信號 、來自任務(wù) 或 中斷的消 息、 信號量。 RTX51 Tiny 是 RTX51 Full 的一個 子集 。 RTX51 Tiny 可以 很容易 的 運 行在沒 有 擴展外部存儲器 的單 片機 系統(tǒng)上。 但 是,使用 RTX51 Tiny 的程 序 可以 訪問外部 存儲器 。 RTX51 Tiny允許循環(huán)任務(wù)切換,并且支持信號傳遞,還能并行的利用中斷功能。 RTX51 Tiny 的 os_wait函數(shù) 可以 等待 以 下事 件 : 時間 到、 時間間 隔、來自 任務(wù) 或者 中斷的信號。 以 后 的 部分 用 RTX-51 來指代 RTX-51 Full 和 RTX-51 Tiny。在兩 者之 間不同的 地方會加 以 說明 。 導(dǎo) 言 許多 微處 理 器 應(yīng)用 都需要 同時 執(zhí) 行多個作業(yè) 或者 任務(wù)。 對 于 這 種應(yīng)用,一個實時的操作系統(tǒng)( RTOS)允許系統(tǒng) 資源 ( CPU、內(nèi)存等 ) 被靈活 的 分配給 幾個任務(wù)。 RTX-51是一個強大的實時操作系統(tǒng),并且 易 于應(yīng)用。 RTX-51 可以工作在 8051系 列 的 微處 理 器 上。 你使用 標準 C語言編寫 RTX-51應(yīng)用程 序 ,并且用 C51來編譯它 們 。 為了 具 體指明 任務(wù)的 標志 和優(yōu)先 級 , 會 與 標準 C存 在一 點差別 。 RTX-51應(yīng)用程 序要求 你 將 RTX51.H或者 RTX51TNY.H頭文 件 包含 進 來 。 當 你在 Vision2集成環(huán) 境里打 開 目標選項對話 框 , 選 擇 目標 操作系統(tǒng)以 后 , 鏈接 器 便 會 添 加 合 適的RTX-51庫 文 件。 單任務(wù)程序 一個 標準 C程 序 從主 函數(shù) 開始 執(zhí) 行。在 嵌入式 應(yīng)用 里 , 主 函數(shù) 經(jīng)常 被編寫為一個 無窮 循環(huán), 也 可以 被 認 為 是一個 連續(xù) 執(zhí) 行的單個任 務(wù)。 例如 : 2 循環(huán)任務(wù)切換 RTX51 Tiny 允許 “ 準 并行 ” 的同時 執(zhí) 行幾個任務(wù)。 每 一個任務(wù)在 預(yù) 先 定義好 的時間 片內(nèi) 得以 執(zhí) 行。時間 到 使 正 在 執(zhí) 行的任務(wù) 掛起 ,并使 另 一個任務(wù)開始 執(zhí)行。 下 面 的 例 子 使用 了 循環(huán)任務(wù)切換的 技術(shù) 。 使用 RTX51的 C程 序 例 子 RTX51 從 任務(wù) 0( 分配給 作業(yè) 0)開始 執(zhí) 行程 序 。 os_create_task 函數(shù)標 記任務(wù) 1( 分配給 作業(yè) 1) 為準 備 執(zhí) 行。 這 兩個任務(wù)是簡單的計 數(shù) 循環(huán)。在一個時間片 結(jié)束 后 , RTX51 中斷作業(yè) 0,并且開始 執(zhí) 行作業(yè) 1。作業(yè) 1 在一個時間 片 結(jié)束 后 ,系統(tǒng) 重新 開始 執(zhí) 行作業(yè) 0。 os_wait 函數(shù) os_wait 函數(shù) 提供 了 一種 更 為 有 效 的 方 式 來給 幾個任務(wù) 分配 可使用的 處 理 器 時間。 os_wait函數(shù) 中斷 當 前正 在 運 行的任務(wù),并且 等待 特定 的 事 件。在一個任務(wù)等待事 件的時間 里 , 其他 任務(wù)可以 被執(zhí) 行。 等待時間到 RTX51使用 8051 的一個 定 時 器來 產(chǎn)生 一個循環(huán)的中斷(時 鐘周期 )。 響 應(yīng) 3 os_wait 的 最 簡單 事 件是時間 到 , 當 前正 在 執(zhí) 行的任務(wù) 被指 定 的時 鐘周期所 中斷。 下 面 的 延 時 例 子 使用的是時間 到 。 使用 os_wait 函數(shù)編 程 這 個程 序 與上一個程 序 相似 ,不同的是作業(yè) 0 是在計 數(shù)器 0 完 成 計 數(shù)后 os_wait函數(shù) 所 中斷的。 RTX51等待 3 個時 鐘周期直 到 作業(yè) 0 準 備好再次 運 行 為 止 。在 這期 間,作業(yè) 1得以 執(zhí) 行。作業(yè) 1 也調(diào) 用 了 os_wait 函數(shù) , 等待 5 個時 鐘周期 。 結(jié)果 是 : 定 時 器 0 每三 個時 鐘周期增 加 一 次 ,計 數(shù)器 1則每 5個時 鐘周期增 加 一 次 。 等待信號 os_wait 函數(shù) 的 另 一個 事 件是信號。信號 被 用 來 協(xié)調(diào) 任務(wù)。 直 到 另 一個任務(wù)發(fā) 出 信號,在 os_wait 函數(shù) 控 制 下 的任務(wù) 才結(jié)束 等待 狀 態(tài) 。 如果 信號 預(yù) 先 就 被 發(fā)送 出 來 , 那么 任務(wù) 將 立即繼 續(xù) 執(zhí) 行。 使用 等待 信號的程 序 4 在 這 個 例 子當 中,任務(wù) 1等待 著由 任務(wù) 0發(fā) 出 的信號,并且以 此 來處 理計 數(shù)器 0產(chǎn)生 的 溢 出 。 搶先任務(wù)切換 RTX51 Full 提供 了 搶 先的任務(wù)切換, RTX51 Tiny 不具 備 這 個功能。 為了對多任務(wù)的 概念 有一個 完 整 的 了 解 ,在 這里對 搶 先任務(wù)切換 加 以 解釋 。 在上一個 例 子 中,任務(wù) 1收 到 一個信號 后 不 會 立即 開始, 只 有 當 任務(wù) 0 發(fā) 生 了 時間 到事 件 后 ,任務(wù) 1才 會 啟動 。 如果 任務(wù) 1被 賦予 了 比 任務(wù) 0 高 的優(yōu)先 級 , 通過搶先任務(wù)切換, 如果 任務(wù) 1收 到了 信號, 就 會 立即 開始。優(yōu)先 級 在任務(wù) 定義 中 被指定 ( 默 認 的優(yōu)先 級 是 0)。 RTX51 的技術(shù)參 數(shù) 描述 RTX-51 Full RTX-51 Tiny 任務(wù) 數(shù) 量 最 多 256個 ; 可同時 激活 19個 16個 RAM需求 40 到 46 字 節(jié) DATA空間 20 到 200字 節(jié) IDATA空間 (用 戶堆棧 ) 最 小 650字 節(jié) XDATA空間 7字 節(jié) DATA空 間 3倍 于任務(wù) 數(shù) 量的IDATA空 間 代 碼 要求 6KB到 8KB 900字 節(jié) 5 硬 件 要求 定 時 器 0 或 定 時 器 1 定 時 器 0 系統(tǒng)時 鐘 1000 到 40000個 周期 1000到 65535個 周期 中斷 請 求 時間 小 于 50個 周期 小 于 20個 周期 任務(wù)切換時間 70 到 100個 周期 ( 快速任務(wù)) 180 到 700 個 周期 ( 標準 任務(wù)) 取決 于 堆棧 的 負 載 100到 700個 周期 取決 于 堆棧 的 負 載 郵箱系統(tǒng) 8個 分別 帶 有 整 數(shù) 入 口的信箱 不 提供 內(nèi)存 池 最 多 16個 內(nèi)存 池 不 提供 信號量 8 1 位 不 提供 RTX51 程序概覽 下列 表格 里列 出 了 RTX51 的一 些 函數(shù) ,并 帶 有簡 要 的 說明 和 執(zhí) 行時間( 針 對 RTX51 Full)。 函數(shù) 描述 CPU周期 isr_recv_message 收 到 消 息 ( 來自 中斷 調(diào)用 ) 71(具 有消 息 ) isr_send_message 發(fā) 送 消 息 ( 來自 中斷 調(diào)用) 53 isr_send_signal 給 任務(wù)發(fā) 去 信號( 來自中斷 調(diào) 用) 46 os_attach_interrupt 分配 中斷 資源給 任務(wù) 119 os_clear_signal 刪除 一個以 前 發(fā) 送 的信號 57 os_create_task 將 一個任務(wù) 放 入 執(zhí) 行隊 列 中 302 os_create_pool 定義 一個 內(nèi)存 池 644(大 小 20 10 字節(jié) ) os_delete_task 從 執(zhí) 行 隊 列 中 移走 一個任務(wù) 172 os_detach_interrupt 移走 一個 分配 的中斷 96 os_disable_isr 禁 止 8051硬 件中斷 81 os_enable_isr 允許 8051硬 件中斷 80 os_free_block 歸 還一 塊 存儲 空 間 給內(nèi)存 池 160 os_get_block 從 內(nèi)存 池獲 得一 塊 存儲 空 間 148 6 os_send_message 發(fā) 送 一 條 消 息 ( 從 任務(wù)中 調(diào) 用) 443(具有任務(wù)切換) os_send_signal 向 任務(wù)發(fā) 送 一個信號( 從 任務(wù)中 調(diào) 用) 408(具有任務(wù)切 換) 316(具有 快速 任務(wù)切換) 71( 沒 有任務(wù)切換) os_send_token 發(fā) 送 一個信號量( 從 任務(wù)中 調(diào) 用) 343(具有 快速 任務(wù)切換) 94( 沒 有任務(wù)切換 os_set_slice 設(shè) 置 RTX51系統(tǒng)時 鐘 時間 片 67 os_wait 等待事 件 68(用于 等待 信號) 160(用于 等待 消 息 ) 標 記 的 函數(shù) 僅僅 在 RTX51 Full中具 備 RTX51 Full里 附 加 的 調(diào) 試 和支持 函數(shù) 見 下 表 : 函數(shù) 描述 oi_reset_int_mask 禁 止 RTX-51 的 外部 中斷 資源 oi_set_int_mask 允許 RTX-51 的 外部 中斷 資源 os_check_mailbox 返回 指 定 信箱的 狀 態(tài) 信 息 os_check_mailboxes 返回 所 有的系統(tǒng)信箱的 狀 態(tài) 信 息 os_check_pool 返回 內(nèi)存 池 中的 塊 信 息 os_check_semaphore 返回 指 定 信號量的 狀 態(tài) 信 息 os_check_semaphores 返回 所 有的系統(tǒng)信號量信 息 os_check_task 返回 指 定 任務(wù)的 狀 態(tài) 信 息 os_check_tasks 返回 所 有的系統(tǒng)任務(wù)的 狀 態(tài) 信 息 CAN 函數(shù) CAN函數(shù) 僅 在 RTX-51 Full中 提供 。 CAN控 制 器 支持 非 利 浦 82C200和 80C592以及 英 特 爾 82526。 更 多的 CAN控 制 器 正 在 準 備 中。 CAN函數(shù) 描述 can_bind_obj 為 一個任務(wù) 綁 定 一個 對 象; 當對 象 被接 收 的時 候 ,任務(wù) 啟動 can_def_obj 定義 通 信 對 象 can_get_status 獲取 CAN控 制 器 狀 態(tài) can_hw_init 初 始 化 CAN控 制 器 硬 件 can_read 直接 讀取 一個 對 象 的 數(shù) 據(jù) 7 can_receive 接 收 所 有 無 界 的 對 象 can_request 向 一個 指 定 的 對 象 發(fā) 送 一個 遠 程 幀 can_send 通過 CAN總線 發(fā) 送 一個 對 象 can_start 開始 CAN通 信 can_stop 結(jié)束 CAN通 信 can_task_create 創(chuàng)建 CAN通 信任務(wù) can_unbind_obj 斷開任務(wù)和 對 象 之 間的 綁 定 can_wait 等待 一個 約 束 的 對 象 被 接 收 can_write 向 一個 對 象 寫 入新 數(shù) 據(jù) ,不用發(fā) 送 TRAFFIC:使用 RTX-51 Tiny 的例程 TRAFFIC例 程是一個行 人 信號 燈 控 制 器 , 通過 它 來說明 多任務(wù)實時操作系統(tǒng)RTX-51 Tiny 的應(yīng)用。在一個用 戶 定義 的時間 段 里 , 交 通燈 受 到 控 制。在時間 段以 外 , 黃色 燈 閃爍 。 如果 一個 步 行 者 按 下了 請 求 按鈕 , 交 通燈立即 進 入 行走 狀 態(tài) 。否 則 , 交 通燈 持 續(xù) 不斷的工作。 交通燈控制器命令 下 表 列 出 了 TRAFFIC所 支持的一系 列 命令 。 這 些 命令 由 ASCII文 本 字 符構(gòu) 成 。 所 有的 命令必須 以 回 車符 來 終 止 。 命令 連續(xù) 的 文 本 描述 Display D 顯示 時 鐘 ,開始和 結(jié)束時間 Time T hh:mm:ss 設(shè) 置 當 前 時間 為 24小時 格 式 Start S hh:mm:ss 設(shè) 置 開始時間 為 24小時 格 式 。 交 通 控 制 通 常 在開始和 結(jié)束 的 時間 段 里 操作,在 此 時間 段 以 外 , 黃色 燈 閃爍 。 End E hh:mm:ss 設(shè) 置 結(jié)束 時間 為 24小時 格 式 軟件 TRAFFIC 應(yīng)用程 序 由 3個 文 件 組 成 , 這 些 文 件可以 8 KEILC51EXAMPLESTRAFFIC 文 件 夾 里 找 到 。 TRAFFIC.C 包含了 交 通燈 控 制程 序 , 被分成了 如 下 幾個任務(wù) : 任務(wù) 0 初始化 : 初 始 化 串 口 ,并且 啟動 所 有 其他 的任務(wù)。 由 于 初 始 化只 需要進行一 次 ,任務(wù) 0將自 己 刪除 自 己 。 任務(wù) 1 命令 : 任務(wù) 1完 成 交 通燈 控 制 器 的 命令 處 理。 這 個任務(wù) 負 責 控 制和 處理 接 收 到 的 串 行 命令 。 任務(wù) 2 時鐘 : 控 制時 鐘 。 任務(wù) 3 閃爍 :當 時間 落 在 活 躍 的時間 段 以 外后 , 黃色 燈 閃爍 。 任務(wù) 4 燈 :當 時間 落 在 活 躍 的時間 段 (在開始和 結(jié)束 時間 之 間) 里 以 后 ,控 制 交 通燈 的 相 位 。 任務(wù) 5 讀按鍵 : 讀取 行 人 按 下 的 按鈕 ,并且 向 任務(wù) 4發(fā) 送 信號。 任務(wù) 6 退出 : 如果 在 串 行 指 令流 里 遇 到了 ESC字 符 ,任務(wù) 1獲 得一個信號,并且 終 止 顯示命令 。 SERIAL.C 執(zhí) 行一個中斷 來 驅(qū) 動 串 行 口 。 這 個 文 件 包含了函數(shù) putchar 和 getkey 。 高 級 的 輸 入 輸 出 函數(shù) printf 和 getline 調(diào) 用 這 些 基 本的 輸 入 輸 出 子函數(shù) 。 沒 有中斷 驅(qū) 動 串 行 輸 入 輸 出 , 交 通燈 應(yīng)用程 序 也 會 啟動 , 但 不 會 完 成 任務(wù)。 GETLINE.C 是一個 命令 行 編 輯 器 ,用 來編 輯 從 串 口 接 收 到 的 字 符 。 這 個 源文 件 也被 測量 應(yīng)用程 序 所 使用。 TRAFFIC 工程 在 Vision2 環(huán) 境里 , 打 開 位 于 KEILC51EXAMPLESTRAFFIC 文 件 夾 里TRAFFIC.UV2文 件。在 工程窗口 的 文件 頁 里將會 看 到源文 件。 在 目標選項里選 擇 RTX-51 Tiny Real-Time OS。 選 擇 工程 編譯 或者 工具 欄 上的 編譯 按鈕 , 編譯 TRAFFIC程 序 。 運行 TRAFFIC 9 程序 你可以 使用 Vision2 里 的 仿真 來 測 試 TRAFFIC應(yīng)用程 序 。 下圖 的變量 觀察窗 口 允許你 觀察驅(qū) 動 交 通燈 的 端 口 狀 態(tài) 。 push_key 信號 函數(shù) 模擬 行 人 按 下 按鈕 ,切換 交 通燈 進 入 行走 狀 態(tài) 。 這 個 函數(shù)被 稱 為 按下以通過 工具 按鈕 。 使用 調(diào)試 函數(shù)編輯器 , 打 開 TRAFFIC.INC 文 件。在 目標選項 調(diào)試 初始化文件 里選 擇 這 個 文 件,并且 定義 信號 函數(shù) push_key, 端 口初 始 化 和 按鈕工具 欄 。 注意 : 因 為 在 TRAFFIC.C 模 塊 里 有一個 叫 時 鐘 的 函數(shù) , 所 以 VTREG符 號 Clock 后面 跟 一個 后 引 號( )。 現(xiàn) 在 運 行 TRAFFIC 應(yīng)用程 序 。允許 查看 周期窗口更新 ,在程 序執(zhí) 行 期 間, 通過觀察窗 口 查看交 通燈 。 1 號串口 窗 口 顯示 了 printf 的 輸 出 ,并且允許你 輸 入 下 表 里 描述 的 交 通燈 控 制器 的 命令 。 設(shè) 置 時間在開始 結(jié)束 時間 段 以 外 , 讓黃色 燈 閃爍 。 RTX 內(nèi)核調(diào)試 10 一個 RTX應(yīng)用程 序 能 夠 使用同 標準 8051 應(yīng)用程 序 相 同的 方 法 和 命令 進 行 測試 。 當 你在 目標選項 目標 里選 擇 了 一種操作系統(tǒng), Vision2 能 夠 允許 附 加 的調(diào) 試 特 性 : 一個 對話 框 列 出 了 操作系統(tǒng) 狀 態(tài) ,并且 當 一個任務(wù)是 活 躍 的時 候 ,你可以應(yīng)用 _TaskRunning_調(diào) 試 函數(shù)來 終 止 程 序 的 運 行。 下 面 的 部分 通過 TRAFFIC例 程 來 解釋 RTX的 調(diào) 試 。 停 止 程 序 的 運 行,復(fù) 位 CPU, 取 消 所 有斷 點 。 一個 RTX-51應(yīng)用可以 象 標準 應(yīng)用一 樣 使用 相 同的 方 式 來 測 試 。 你可以打開源文件 ,設(shè) 置 斷 點 ,單 步 執(zhí) 行。 TRAFFIC應(yīng)用 從 任務(wù) 0 初始化 開始 啟動 。 通過 Vision2 可以 完 全清楚 的 了 解 內(nèi) 核 。你可以使用 菜 單 命令 外設(shè) RTX Tiny任務(wù)列 表 來 顯示 任務(wù) 狀 態(tài) 。 對話 框 RTX Tiny 任務(wù)列 表 向 你 顯示 了 如 下 信 息: 頭 描述 TID 在任務(wù) 函數(shù) 定義 里 使用 task_id Task Name 任務(wù) 函數(shù) 名 字 State 函數(shù) 的任務(wù) 狀 態(tài); 在 下 一個 表 里 詳細 解釋 。 Wait for 任務(wù) 等待 的 事 件 ; 下列事 件是可能的( 也 可以是復(fù) 合 事 件) Event 時間到 : 任務(wù) 計 時器 被 設(shè) 置 為 持 續(xù) 的時間, 該 時間在 os_wait 函數(shù) 調(diào) 用中 被指 定 。 當 計 時器 減 為 0以 后 ,任務(wù) 便 進 入 準 備 狀 態(tài) . 時間間 隔 : 任務(wù) 計 時器 值 被 設(shè) 置 為 時間間 隔 , 該 時間間 隔 在os_wait 函數(shù) 調(diào) 用中 被指 定 。 當 計 時器 減 為 0以 后 ,任務(wù) 便 進 入 準備 狀 態(tài) . 11 信號 : os_wait 函數(shù)被 K_SIG 調(diào) 用,并且任務(wù) 等待 SIG=1。 Sig 分配給 任務(wù)的信號 位 的 狀 態(tài) Timer 分配給 任務(wù)的 計 時器 的 值 。計時 器 值 在 每 一個 RTX 系統(tǒng)時 鐘周期后 減 1。 如果 計 時器 的 值 變 為 0,并且任務(wù) 等待 時間到 或 時間間 隔 事件, 那么 任務(wù)進 入 準備 狀 態(tài) 。 Stack 當 任務(wù) 運行 時, 被 使用的 堆棧 指 針 ( SP)的 值 RTX-51 Tiny 包 含了 一個有 效 地 堆棧 管理 器 , 該 管理 器 在 “ RTX51 Tiny”用戶指南 第 五 章: RTX51 Tiny, 堆棧 管理 器 中 被 解釋 。 該手冊 提供 了 詳細 的 堆棧 值 的信 息 。 狀 態(tài) 描述 Deleted 尚 未 啟動 的任務(wù) 處 于 刪除 狀 態(tài) 。 Ready 等待執(zhí) 行的任務(wù) 處 于 準備 狀 態(tài) 。 當 正 在進行的任務(wù) 結(jié)束 后 ,RTX 啟動 下 一個 處 在 準備 狀 態(tài) 下 的任務(wù)。 Running 當 前正 在 運 行的任務(wù) 處 于 運行 狀 態(tài) ,在同一時 刻 , 僅僅 有一個任務(wù) 處 于 運行 狀 態(tài) 。 Timeout 被 循環(huán)任務(wù)切換時間 到事 件 所 中斷的任務(wù) 處 于 時間到 狀 態(tài) ,這 個 狀 態(tài) 與 等待 狀 態(tài) 等 價 ; 但 是,循環(huán)任務(wù)切換是 根 據(jù) 內(nèi)部 的操作 過 程 被標 記 的。 Waiting 等待事 件的任務(wù) 處 于 等待 狀 態(tài) 。 如果 一個任務(wù) 正 在 等待 的 事件發(fā) 生 了 , 該 任務(wù) 就 進 入 準備 狀 態(tài) 。 只 有 當 在 _TakRunning_調(diào) 試 函數(shù) 聲 明里指 定 的任務(wù) 正在 運行 時, 調(diào)試 斷點 對話框 允許你 定義 停 止 程 序運 行的斷 點 。 參考 “預(yù)定義 函數(shù) ” ,可以 找 到 關(guān) 于_TakRunning_調(diào) 試 函數(shù) 的 詳細 描述 。 僅僅 當 此 刻 正在 運行 的任務(wù)是 燈 的時 候 ,在 signalon函數(shù)里 的斷 點 才 會 停 止程 序 的 執(zhí) 行。 12 附件 2:外文原文 (復(fù)印件) RTX-51 Real-Time Operating System RTX51 is a multitasking real-time operating system for the 8051 family. RTX51simplifies system and software design of complex and time-critical projects.RTX51 is a powerful tool to manage several jobs (tasks) on a single CPU. Thereare two distinct versions of RTX51: RTX51 Full which performs both round-robin and preemptive task switchingwith 4 task priorities and can be operated with interrupt functions in parallel.RTX51 supports signal passing; message passing with a mailbox system andsemaphores. The os_wait function of RTX51 can wait for the following events:interrupt; timeout; signal from task or interrupt; message from task or interrupt;semaphore.RTX51 Tiny which is a subset of RTX51 Full. RTX51 Tiny easily runs onsingle-chip systems without off-chip memory. However, program using RTX51Tiny can access off-chip memory. RTX51 Tiny allows round-robin taskswitching, supports signal passing and can be operated with interrupt functionsin parallel. The os_wait function of RTX51 Tiny can wait for the following events: timeout; interval; signal from task or interrupt.The rest of this section uses RTX-51 to refer to RTX-51 Full and RTX-51 Tiny.Differences between the two are stated where applicable. Introduction Many microcontroller applications require simultaneous execution of multiplejobs or tasks. For such applications, a real-time operating system (RTOS) allowsflexible scheduling of system resources (CPU, memory, etc.) to several tasks.RTX-51 implements a powerful RTOS that is easy to use. RTX-51 works withall 8051 derivatives. You write and compile RTX-51 programs using standard C constructs andcompiling them with C51. Only a few deviations from standard C are requiredin order to specify the task ID and priority. RTX-51 programs also require thatyou include the RTX51.H or RTX51TNY.H header file. When you select in theVision2 dialog Options for Target - Target the operating system, the linker addsthe appropriate RTX-51 library file. Single Task Program A standard C program starts execution with the main function. In an embeddedapplication, main is usually coded as an endless loop and can be thought of as asingle task that is executed continuously. For example: 13 Round-Robin Task Switching RTX51 Tiny allows a quasi-parallel, simultaneous execution of several tasks.Each task is executed for a predefined timeout period. A timeout suspends theexecution of a task and causes another task to be started. The following exampleuses this round-robin task switching technique. Simple C Program using RTX51 RTX51 starts the program with task 0 (assigned to job0). The functionos_create_task marks task 1 (assigned to job1) as ready for execution. Thesetwo functions are simple count loops. After the timeout period has beencompleted, RTX51 interrupts job0 and begins execution of job1. This functioneven reaches the timeout and the system continues with job0. The os_wait Function The os_wait function provides a more efficient way to allocate the availableprocessor time to several tasks. os_wait interrupts the execution of the currenttask and waits for the specified event. During the time in which a task waits foran event, other tasks can be executed. Wait for Timeout RTX51 uses an 8051 timer in order to generate cyclic interrupts (timer ticks).The simplest event argument for os_wait is a timeout, where the currentlyexecuting task is interrupted for the specified number of timer ticks. Thefollowing uses timeouts for the time delay. Program with os_wait Function 14 This program is similar to the previous example with the exception that job0 isinterrupted with os_wait after counter0 has been incremented. RTX51 waitsthree timer ticks until job0 is ready for execution again. During this time, job1 isexecuted. This function also calls os_wait with a timeout of 5 ticks. The result:counter0 is incremented every three ticks and counter1 is incremented every fivetimer ticks. Wait for Signal Another event for os_wait is a signal. Signals are used for task coordination: ifa task waits with os_wait until another task issues a signal. If a signal waspreviously sent, the task is immediately continued. Program with Wait for Signal. In this example, task 1 waits for a signal from task 0 and therefore processes theoverflow from counter0. Preemptive Task Switching 15 The full version of RTX51 provides preemptive task switching. This feature isnot included in RTX51 Tiny. It is explained here to provide a completeoverview of multitasking concepts. In the previous example, task 1 is not immediately started after a signal hasarrived, but only after a timeout occurs for task 0. If task 1 is defined with ahigher priority than task 0, by means of preemptive task switching, task 1 isstarted immediately after the signal has arrived. The priority is specified in thetask definition (priority 0 is the default value). RTX51 Technical Data Description RTX-51 Full RTX-51 Tiny Number of tasks 256; max. 19 tasks active 16 RAM requirements 40 . 46 bytes DATA 20 . 200 bytes IDATA (user stack) min. 650 bytes XDATA 7 bytes DATA 3 * IDATA Code requirements 6KB . 8KB 900 bytes Hardware requirements timer 0 or timer 1 timer 0 System clock 1000 . 40000 cycles 1000 . 65535 cycles Interrupt latency 50 cycles 20 cycles Context switch time 70 . 100 cycles (fast task) 180 . 700 cycles (standard task) depends on stack load 100 . 700 cycles depends on stack load Mailbox system 8 mailboxes with 8 integer entries each not available Memory pool system up to 16 memory pools not available Semaphores 8 * 1 bit not available Overview of RTX51 Routines The following table lists some of the RTX-51 functions along with a briefdescription and execution timing (for RTX-51 Full). function Description CPU Cycles sr_recv_message Receive a message (call from interrupt). 71 (with message) isr_send_message Send a message (call from interrupt). 53 isr_send_signal Send a signal to a task (call from interrupt). 46 os_attach_interrupt Assign task to interrupt 119 16 source. os_clear_signal Delete a previously sent signal. 57 os_create_task Move a task to execution queue. 302 os_create_pool Define a memory pool. 644 (size 20 * 10 bytes) os_delete_task Remove a task from execution queue. 172 os_detach_interrupt Remove interrupt assignment. 96 os_disable_isr Disable 8051 hardware interrupts. 81 os_enable_isr Enable 8051 hardware interrupts. 80 os_free_block Return a block to a memory pool. 160 os_get_block Get a block from a memory pool. 148 os_send_message Send a message (call from task). 443 with task switch os_send_signal Send a signal to a task (call from tasks). 408 with task switch 316 with fast task switch 71 without task switch os_send_token Set a semaphore (call from task). 343 with fast task switch 94 without task switch os_set_slice Set the RTX-51 system clock time slice. 67 os_wait Wait for an event. 68 for pending signal 160 for pending message Function Description These functions are available only in RTX-51 Full. Additional debug and support functions in RTX-51 Full include the following: Function Description oi_reset_int_mask Disables interrupt sources external to RTX-51. oi_set_int_mask Enables interrupt sources external to RTX-51. os_check_mailbox Returns information about the state of a specific mailbox. os_check_mailboxes Returns information about the state of all mailboxes in the system. 17 os_check_pool Returns information about the blocks in a memory pool. os_check_semaphore Returns information about the state of a specific semaphore. os_check_semaphores Returns information about the state of all semaphores in the system. os_check_task Returns information about a specific task. os_check_tasks Returns information about all tasks in the system. CAN Functions The CAN functions are available only with RTX-51 Full. CAN controllerssupported include the Philips 82C200 and 80C592 and the Intel 82526. MoreCAN controllers are in preparation.on CAN Function Description can_bind_obj Bind an object to a task; task is started when object is received. can_def_obj Define communication objects. can_get_status Get CAN controller status. can_hw_init Initialize CAN controller hardware. can_read Directly read an objects data. can_receive Receive all unbound objects. can_request Send a remote frame for the specified object. can_send Send an object over the CAN bus can_start Start CAN communications. can_stop Stop CAN communications. can_task_create Create the CAN communication task. can_unbind_obj Disconnect the binding between a task and an object. can_wait can_write Wait for reception of a bound object. Write new data to an object without sending it. TRAFFIC: RTX-51 Tiny Example Program The TRAFFIC example is a pedestrian traffic light controller that shows theusage of multitasking RTX-51 Tiny Real-time operating system. D

溫馨提示

  • 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)容負責。
  • 6. 下載文件中如有侵權(quán)或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論