【正文】
re simple count loops. After the timeout period has beenpleted, 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 pleteoverview 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 RTX51 Full RTX51 Tiny Number of tasks 256。 signal from task or interrupt。 如果 計 時器 的 值 變 為 0,并且任務 等待 時間到 或 時間間 隔 事件, 那么 任務進 入 準備 狀 態(tài) 。 設 置 時間在開始 / 結束 時間 段 以 外 , 讓黃色 燈 閃爍 。 是一個 命令 行 編 輯 器 ,用 來編 輯 從 串 口 接 收 到 的 字 符 。 命令 連續(xù) 的 文 本 描述 Display D 顯示 時 鐘 ,開始和 結束時間 Time T hh:mm:ss 設 置 當 前 時間 為 24小時 格 式 Start S hh:mm:ss 設 置 開始時間 為 24小時 格 式 。 為了對多任務的 概念 有一個 完 整 的 了 解 ,在 這里對 搶 先任務切換 加 以 解釋 。 os_wait函數 中斷 當 前正 在 運 行的任務,并且 等待 特定 的 事 件。 你使用 標準 C語言編寫 RTX51應用程 序 ,并且用 C51來編譯它 們 。 RTX51使復雜的系統和軟件設計以及有時間限制的工程開發(fā)變得簡單。 對 于 這 種應用,一個實時的操作系統( RTOS)允許系統 資源 ( CPU、內存等 ) 被靈活 的 分配給 幾個任務。在一個時間片 結束 后 , RTX51 中斷作業(yè) 0,并且開始 執(zhí) 行作業(yè) 1。 如果 信號 預 先 就 被 發(fā)送 出 來 , 那么 任務 將 立即繼 續(xù) 執(zhí) 行。 交通燈控制器命令 下 表 列 出 了 TRAFFIC所 支持的一系 列 命令 。 這 個 文 件 包含了函數 putchar 和 getkey 。 現 在 運 行 TRAFFIC 應用程 序 。 當 計 時器 減 為 0以 后 ,任務 便 進 入 準備 狀 態(tài) . 11 信號 : os_wait 函數被 K_SIG 調 用,并且任務 等待 SIG=1。 12 附件 2:外文原文 (復印件) RTX51 RealTime Operating System RTX51 is a multitasking realtime operating system for the 8051 family. RTX51simplifies system and software design of plex and timecritical is a powerful tool to manage several jobs (tasks) on a single CPU. Thereare two distinct versions of RTX51: RTX51 Full which performs both roundrobin and preemptive task switchingwith 4 task priorities and can be operated with interrupt functions in supports signal passing。 explained in detail in the next table. Wait for event the task is waiting for。 Timeout 被 循環(huán)任務切換時間 到事 件 所 中斷的任務 處 于 時間到 狀 態(tài) ,這 個 狀 態(tài) 與 等待 狀 態(tài) 等 價 ; 但 是,循環(huán)任務切換是 根 據 內部 的操作 過 程 被標 記 的。 TRAFFIC應用 從 任務 0 初始化 開始 啟動 。 下圖 的變量 觀察窗 口 允許你 觀察驅 動 交 通燈 的 端 口 狀 態(tài) 。 任務 2 時鐘 : 控 制時 鐘 。 更 多的 CAN控 制 器 正 在 準 備 中。在 這期 間,作業(yè) 1得以 執(zhí) 行。 每 一個任務在 預 先 定義好 的時間 片內 得以 執(zhí) 行。 但 是,使用 RTX51 Tiny 的程 序 可以 訪問外部存儲器 。 RTX51 Tiny 可以 很容易 的 運 行在沒 有 擴展外部存儲器 的單 片機 系統上。 例如 : 2 循環(huán)任務切換 RTX51 Tiny 允許 “ 準 并行 ” 的同時 執(zhí) 行幾個任務。 RTX51等待 3 個時 鐘周期直 到 作業(yè) 0 準 備好再次 運 行 為 止 。 CAN控 制 器 支持 非 利 浦 82C200和 80C592以及 英 特 爾 82526。 這 個任務 負 責 控 制和 處理 接 收 到 的 串 行 命令 。 運行 TRAFFIC 9 程序 你可以 使用 μ Vision2 里 的 仿真 來 測 試 TRAFFIC應用程 序 。 你可以打開源文件 ,設 置 斷 點 ,單 步 執(zhí) 行。 Running 當 前正 在 運 行的任務 處 于 運行 狀 態(tài) ,在同一時 刻 , 僅僅 有一個任務 處 于 運行 狀 態(tài) 。 task is started when object is received. can_def_obj Define munication objects. can_get_status Get CAN controller status. can_hw_init Initialize CAN controller hardware. can_read Directly read an object’s 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 munications. can_stop Stop CAN munications. can_task_create Create the CAN munication 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: RTX51 Ti