網頁

2013年12月22日 星期日

[RTOS] Introduction to FreeRTOS

 

FreeRTOS 是一個 open source 的 RTOS, 應用在 embedded system . FreeRTOS 的授權方式採用 GPL, 但是有選擇性的例外. 這部份指的是, 採用 FreeRTOS 的系統, 除了 kernel,  也就是 FreeRTOS 的部份, 必須遵守 GPL 以外, 使用者自己專有的原始碼, 不需因此感染而成為 open source.

FreeRTOS 的特性

Thread, mutex, semaphore, soft-timer.

Tick-less mode

大部份現在 embedded system 的處理器, 為了追求省電, 都會有深層的睡眠模式. 在深層的模式下, 有時連 timer 都會關掉. Tick-less mode 就是為了適應這種狀況下還能正常工作.

Memory allocation schema

FreeRTOS 有 4 種 memory allocation 的 schema

1. allocate only

2. allocate and free, simple algorithm

3. allocate and free, complex algorithm’'

4. C library allocate and free with mutural execution protection

Memory allocation schema

Thread library vs. Operation system

相較來說, FreeRTOS 更像是 thread library, 而不像 operation system. Host program 維護一組 thread, 並且在一定時間內, 輪詢這些 thread, 並呼叫這些 thread 的 tick function.

換句話說, context switch 並不是由 interrupt 觸發, 再進到 OS 層來做 context switch, 而是由使用者的程式 ( host program) 來分配 thread 的作業時間. 這樣的架構, 有兩個問題必須特別注意.

1. 長時間佔用的問題, 因為 OS 沒有強制奪取執行序列的能力, 會不會有一個 thread 佔用太長的作業時間, 沒有交還 CPU 的控制權. 這樣的狀況會不會發生, 如果發生, 應該如何因應 ?

2. 系統反應時間的問題, 必須立刻反應的動作, 也要等到 host program 輪詢到才能開始運作. 系統反應時間較長, 且不能預期完成反應的時間.

沒有留言:

張貼留言

請提供您寶貴的意見