日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

OS_CORE.C(5)

發布時間:2025/3/21 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 OS_CORE.C(5) 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
/*$PAGE*/ /* ********************************************************************************************************* * ENTER ISR * 進入中斷(執行中斷) * Description: This function is used to notify uC/OS-II that you are about to service an interrupt * service routine (ISR). This allows uC/OS-II to keep track of interrupt nesting and thus * only perform rescheduling at the last nested ISR.該功能用來通知uc/os-II,正在進行一個中斷服務。該功能可以使uc/os-II追蹤中斷嵌套信息并且只能在最后嵌套中斷 * * Arguments : none * * Returns : none * * Notes : 1) This function should be called ith interrupts already disabled在任務級不能調用該函數 * 2) Your ISR can directly increment OSIntNesting without calling this function because * OSIntNesting has been declared 'global'.如果系統使用的處理器能夠執行自動的獨立執行讀取-修改-寫入的操作,那么就可以直接遞增265 * 中斷嵌套層數(OSIntNesting),這樣可以避免調用函數所帶來的額外開銷。在中斷服務子程序中266 * 給OSIntNesting加1是不會有問題的,因為給OSIntNesting加1時,中斷是關閉的 * 3) You MUST still call OSIntExit() even though you increment OSIntNesting directly.必須要有OSIntNesting()函數 * 4) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the * end of the ISR. -- OSIntEnter()和OSIntExit()成對出現 * 5) You are allowed to nest interrupts up to 255 levels deep.中斷深度可達255 * 6) I removed the OS_ENTER_CRITICAL() and OS_EXIT_CRITICAL() around the increment because * OSIntEnter() is always called with interrupts disabled. ********************************************************************************************************* */void OSIntEnter(void) {if (OSRunning == OS_TRUE) {if (OSIntNesting < 255u) { /*如果中斷層次<255*/OSIntNesting++; /* Increment ISR nesting level 增加中斷嵌套層次 */}} } /*$PAGE*/ /* ********************************************************************************************************* * EXIT ISR * 退出中斷(中斷完成) * Description: This function is used to notify uC/OS-II that you have completed serviving an ISR. When * the last nested ISR has completed, uC/OS-II will call the scheduler to determine whether * a new, high-priority task, is ready to run. * 該功能用來通知uc/os-II已完成中斷。當最后一個中斷嵌套完成時,uc/os-II將調用調度程序確定是否有個新的高優先級的任務準備運行 * Arguments : none * * Returns : none * * Notes : 1) You MUST invoke OSIntEnter() and OSIntExit() in pair. In other words, for every call * to OSIntEnter() at the beginning of the ISR you MUST have a call to OSIntExit() at the * end of the ISR.OSIntEnter()和OSIntExit()配套使用 * 2) Rescheduling is prevented when the scheduler is locked (see OS_SchedLock()) 給調度器上鎖用于禁止任務調度 (查看 OSSchedLock()函數) ********************************************************************************************************* */void OSIntExit(void) { #if OS_CRITICAL_METHOD == 3u /* Allocate storage for CPU status register為CPU狀態寄存器分配存儲空間 */OS_CPU_SR cpu_sr = 0u; #endifif (OSRunning == OS_TRUE) { /*如果操作系統還在運行,關閉中斷*/OS_ENTER_CRITICAL();if (OSIntNesting > 0u) { /* Prevent OSIntNesting from wrapping 如果嵌套>0層,嵌套層減1 */OSIntNesting--;}if (OSIntNesting == 0u) { /* Reschedule only if all ISRs complete ...所有的中斷都完成了 */if (OSLockNesting == 0u) { /* ... and not locked.并且嵌套鎖也沒有了 */OS_SchedNew(); /*進行新一輪的調用*/OSTCBHighRdy = OSTCBPrioTbl[OSPrioHighRdy];/*在任務優先級表中找到最高優先級任務*/if (OSPrioHighRdy != OSPrioCur) { /* No Ctx Sw if current task is highest rdy檢查具有最高優先級別的就緒任務的優先級是否是正在運行的任務的優先級 */ #if OS_TASK_PROFILE_EN > 0u /*如果不是*/OSTCBHighRdy->OSTCBCtxSwCtr++; /* Inc. # of context switches to this task 進行上下文切換 */ #endifOSCtxSwCtr++; /* Keep track of the number of ctx switches上下文切換的次數(統計任務計數器) */OSIntCtxSw(); /* Perform interrupt level ctx switch 做中斷任務切換 */}}}OS_EXIT_CRITICAL(); /*打開中斷*/} }



總結

以上是生活随笔為你收集整理的OS_CORE.C(5)的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。