即時作業系統是如何演進的
發現從使用硬體中斷,到即時作業系統(RTOS)之間有演進的程序。
1.Round-Robin:不使用中斷,只使用輪詢方式,做為排程。
2.Foreground/Background:只使用中斷,利用硬體排程。
3.Round-Robin with Interrupt:使用中斷及輪詢混合式排程。
4.Coroutine:將輪詢方式的排程改為經由軟體呼叫方式切換。並加入排程工作鏈,管理工作加入及移除。
5.Real-Time Operating System:現代即時作業系統,函式一下子增加了許多。工作切換可以利用設定事件(Event)方式,設定排程的條件。
前三種及RTOS在uCOS的書中有介紹,但Bee認為奇怪的是為何工作排程一下子變的如此複雜。
在使用中斷管理及現代作業系統之間,一定存在軟體可以管理,但又沒有強制切換的管理系統。
不幸的是,中間型式就像物種進化中的失落環節一樣,幾乎找不到資料。
後來才從Forth語言及Lua語言上找到Coroutine,Bee才確定有Coroutine這型排程管理系統存在。
以下就功能特性做一個比較:
1.Round-Robin:
特性:這是最簡單的排程系統,但時間控制不精準。
Task Control : Pulling
Time Function : Depend on assemble code or instruction delay
Data Exchange : Global variable
State Machine : Run on open loop,state control by data


2.Foreground/Background:
特性:將需要精準時間控制的工作放入中斷。
Task Control : Interrupt
Time Function : In interrupt using counter control function call
Data Exchange : User control with protected global variable
State Machine : Run on open loop,state control by data
要解決問題:變數保護問題,假設有一個函式如下。
int temp;
void swap( int *x, int *y)
{
temp = *x;
*x = *y;
*y = temp;
}
這個函式若由main()及中斷中都有使用到,則會發生變數衝突問題。這個問題則要由工程師自己注意。

3.Round-Robin with Interrupt:
特性:加入多種工作時,要改成這個結構。
Task Control : Interrupt/Pulling
Time Function : Interrupt Function/Interrupt Flag to Round-Robin Function
Data Exchange : User control with protected global variable/Global Variable
State Machine : Run on open loop,state control by data

4.Coroutine:
特性:加入工作管理,可以加入及移除工作項目
Task Control : O.S. Function/Interrupt
Time Function : Interrupt Function / O.S. Function
Data Exchange : Global Variable
State Machine : Program Structure Control



5.Real-Time Operating System:
特性:現在作業系統功能
Task Control : O.S. Function
Time Function : O.S. Function
Data Exchange : O.S. Function
State Machine : Program Structure Control

1.Round-Robin:不使用中斷,只使用輪詢方式,做為排程。
2.Foreground/Background:只使用中斷,利用硬體排程。
3.Round-Robin with Interrupt:使用中斷及輪詢混合式排程。
4.Coroutine:將輪詢方式的排程改為經由軟體呼叫方式切換。並加入排程工作鏈,管理工作加入及移除。
5.Real-Time Operating System:現代即時作業系統,函式一下子增加了許多。工作切換可以利用設定事件(Event)方式,設定排程的條件。
前三種及RTOS在uCOS的書中有介紹,但Bee認為奇怪的是為何工作排程一下子變的如此複雜。
在使用中斷管理及現代作業系統之間,一定存在軟體可以管理,但又沒有強制切換的管理系統。
不幸的是,中間型式就像物種進化中的失落環節一樣,幾乎找不到資料。
後來才從Forth語言及Lua語言上找到Coroutine,Bee才確定有Coroutine這型排程管理系統存在。
以下就功能特性做一個比較:
1.Round-Robin:
特性:這是最簡單的排程系統,但時間控制不精準。
Task Control : Pulling
Time Function : Depend on assemble code or instruction delay
Data Exchange : Global variable
State Machine : Run on open loop,state control by data
2.Foreground/Background:
特性:將需要精準時間控制的工作放入中斷。
Task Control : Interrupt
Time Function : In interrupt using counter control function call
Data Exchange : User control with protected global variable
State Machine : Run on open loop,state control by data
要解決問題:變數保護問題,假設有一個函式如下。
int temp;
void swap( int *x, int *y)
{
temp = *x;
*x = *y;
*y = temp;
}
這個函式若由main()及中斷中都有使用到,則會發生變數衝突問題。這個問題則要由工程師自己注意。
3.Round-Robin with Interrupt:
特性:加入多種工作時,要改成這個結構。
Task Control : Interrupt/Pulling
Time Function : Interrupt Function/Interrupt Flag to Round-Robin Function
Data Exchange : User control with protected global variable/Global Variable
State Machine : Run on open loop,state control by data
4.Coroutine:
特性:加入工作管理,可以加入及移除工作項目
Task Control : O.S. Function/Interrupt
Time Function : Interrupt Function / O.S. Function
Data Exchange : Global Variable
State Machine : Program Structure Control
5.Real-Time Operating System:
特性:現在作業系統功能
Task Control : O.S. Function
Time Function : O.S. Function
Data Exchange : O.S. Function
State Machine : Program Structure Control
留言
張貼留言