Danh mục

FREERTOS TASKMANAGEMENT

Số trang: 36      Loại file: pdf      Dung lượng: 491.78 KB      Lượt xem: 5      Lượt tải: 0    
Xem trước 4 trang đầu tiên của tài liệu này:

Thông tin tài liệu:

•Three sources of LCD messages •Mix of fast and slow hardware •Mix of continuous, periodic, event driven, high priority and low priority requirementsBÙI QU C B O 1.Why use RTOSConcurrent processing
Nội dung trích xuất từ tài liệu:
FREERTOS TASKMANAGEMENT ARM PROGRAMMING Bùi Qu c B o Why use RTOS •Three sources of LCD messages •Mix of fast and slow hardware •Mix of continuous, periodic, event driven, high priority and low priority requirementsBÙI QU C B O 1 Why use RTOS Concurrent processingBÙI QU C B O 2 Scheduler Scheduler là 1 ph n c a kernel dùng ñ quy t ñ nh tác v nào ñư c ch y t i m i th i ñi m. Kernel có th d ng và ph c h i ho t ñ ng c a 1 tác v trong khi tác v ñang ch y. M t tác v có th d ng chính nó b ng cách delay (sleep) m t kho ng th i gian, ho c ch (block) ñ ñ i m t s ki n (vd: keypressed) hay 1 tài nguyên (vd: serialport) SchedulerBÙI QU C B O 3 Scheduler At (1) task 1 is executing. At (2) the kernel suspends task 1 ... and at (3) resumes task 2. While task 2 is executing (4), it locks a processor peripheral for its own exclusive access. At (5) the kernel suspends task 2 ... ... and at (6) resumes task 3. Scheduler Task 3 tries to access the same processor peripheral, finding it locked, task 3 cannot continue so suspends itself at (7). At (8) the kernel resumes task 1. Etc. The next time task 2 is executing (9) it finishes with the processor peripheral and unlocks it. The next time task 3 is executing (10) it finds it can now access the processor peripheral and this time executes until suspended by the kernel.BÙI QU C B O 4 Realtime scheduler M i tác v ph i ñáp ng (response) trong th i gian qui ñ nh (deadline). M i tác v có 1 m c ưu tiên riêng Scheduler s ñ m b o tác v có quy n ưu tiên cao luôn ñư c th c thi b ng cách t m d ng tác v có quy n ưu tiên th p. Realtime OS Response time: 0-100ms LCD Keypad Display output Analog Input ADC filter control Sample rate: 5KhzBÙI QU C B O 5 Keypad handler void vKeyHandlerTask( void *pvParameters ) { // Key handling is a continuous process and as such the task // is implemented using an infinite loop (as most real time // tasks are). for( ;; ) { [Suspend waiting for a key press] [Process the key press] } } control void vControlTask( void *pvParameters ) { for( ;; ) { [Suspend waiting for 0.5ms since the start of the previous cycle] [Sample the input] [Filter the sampled input] [Perform control algorithm] [Output result] } }BÙI QU C B O 6 M c ưu tiên Deadline c a tác v control thì nghiêm ng t hơn c a tác v keypad. H u qu c a vi c tr deadline c a tác v control thì l n hơn so v i keypadBÙI QU C B O 7 FreeRTOS realtime kernel Example using FreeRTOS int main( void ){ /* Create the 2 task in exactly the same way. */ xTaskCreate( vTask1, Task 1, 1000, NULL, 1, NULL ); xTaskCreate( vTask2, Task 2, 1000, NULL, 1, NULL ); /* Start the scheduler so our tasks start executing. */ vTaskStartScheduler(); /* If all is well we will never reach here as the scheduler will now be running. If we do reach here then it is likely that there was insufficient heap available for the idle task to be created. */ for( ;; ); return 0; }BÙI QU C B O 8 Example using FreeRTOS void vTask1( void *pvParameters ) { const char *pcTaskName = Task 1 is running\r\n; volatile unsigned long ul; /* As per most tasks, this task is implemented in an infinite loop. */ for( ;; ) { ...

Tài liệu được xem nhiều: