FreeRTOS API RTOS Kernel Control

Started by tha, December 16, 2021, 09:56:56 AM

Previous topic - Next topic

tha

https://www.freertos.org/a00134.html

vTaskSuspendAll
[RTOS Kernel Control]

task. h

void vTaskSuspendAll( void );

ระงับ the scheduler. การระงับ the scheduler ป้องกันไม่ให้ a context switch เกิดขึ้นแต่จะปล่อยให้ interrupts เปิดการใช้งาน. ถ้า an interrupt ร้องขอ a context switch ในขณะที่ the scheduler ถูกระงับ, ดังนั้น the request จะยึดค้างไว้และจะถูกดำเนินการเฉพาะเมื่อ the scheduler ถูกกลับมาทำงานต่อ (ไม่ระงับ).

การเรียกถึง xTaskResumeAll() จะเปลี่ยน the scheduler ออกจาก the Suspended state หลังจากการเรียกก่อนหน้าถึง vTaskSuspendAll().

การเรียกถึง vTaskSuspendAll() สามารถถูกทำให้ซ้อนกันได้. จำนวนเท่ากันของการเรียกต้องถูกทำถึง xTaskResumeAll() ตามที่ถูกทำไปก่อนหน้าถึง vTaskSuspendAll() ก่อน the scheduler จะออกจาก the Suspended state และเข้าสู่ the Active state ใหม่.

xTaskResumeAll() ต้องถูกเรียกเฉพาะจาก an executing task และดังนั้นต้องไม่ถูกเรียกในขณะที่ the scheduler อยู่ใน the Initialization state (ก่อนที่ the scheduler กำลังถูกสตาร์ท).

FreeRTOS API functions อื่นๆต้องไม่ถูกเรียกในขณะที่ the scheduler ถูกระงับ.

API functions ที่มีศักยภาพเป็นเหตุให้เกิด a context switch (ตัวอย่างเช่น, vTaskDelayUntil(), xQueueSend(), etc.) ต้องไม่ถูกเรียกในขณะที่ the scheduler ถูกระงับ.

Example usage:
(ตัวอย่างโค้ดดูในลิ้งค์เอานะครับ)

tha

https://www.freertos.org/a00135.html

xTaskResumeAll
[RTOS Kernel Control]

task. h

BaseType_t xTaskResumeAll( void );

กลับมาทำงานต่อ the scheduler หลังจากมันถูกระงับแล้วโดยใช้การเรียกถึง vTaskSuspendAll().

xTaskResumeAll() กลับมาทำงานต่อเฉพาะ the scheduler เท่านั้น. มันไม่ยกเลิกการระงับ tasks ที่ถูกระงับไปก่อนหน้าโดยการเรียกถึง vTaskSuspend().

Returns:

     ถ้าการกลับมาทำงานต่อ the scheduler เป็นเหตุให้เกิด a context switch ดังนั้น pdTRUE จะถูกส่งคืนกลับ, ถ้าเป็นอย่างอื่น pdFALSE จะถูกส่งคืนกลับ.

Example usage:
(ตัวอย่างโค้ดดูในลิ้งค์เอานะครับ)

tha

https://www.freertos.org/vTaskStepTick.html

vTaskStepTick
[RTOS Kernel Control]

task.h

void vTaskStepTick( TickType_t xTicksToJump );

ถ้า the RTOS ถูกกำหนดค่าเพื่อใช้ tickless idle functionality ดังนั้น the tick interrupt จะถูกหยุด, และ the microcontroller ถูกวางลงใน a low power state, เมื่อไรก็ตามที่ the Idle task เป็น task เดียวที่สามารถปฏิบัติ. เมื่อออกจาก the low power state the tick count value ต้องถูกทำให้ถูกต้องเพื่อรายงานสำหรับเวลาที่ผ่านไปในขณะที่มันถูกหยุด.

ถ้า a FreeRTOS port รวม a default portSUPPRESS_TICKS_AND_SLEEP() implementation, ดังนั้น vTaskStepTick() จะถูกใช้ภายในเพื่อให้แน่ใจว่า the correct tick count value ถูกรักษา. vTaskStepTick() เป็น a public API function ที่ยอมให้ the default portSUPPRESS_TICKS_AND_SLEEP() implementation ถูกแทนที่, และสำหรับ a portSUPPRESS_TICKS_AND_SLEEP() ถูกจัดให้มีถ้า the port ที่กำลังถูกใช้ไม่จัดให้มีค่าเริ่มต้น.

The configUSE_TICKLESS_IDLE configuration constant ต้องถูกเซ็ตเป็น 1 เพื่อ vTaskStepTick() มีให้ใช้เป็นประโยชน์.

Parameters:

     xTicksToJump       จำนวนของ RTOS ticks ที่ผ่านไปตั้งแต่ the tick interrupt ถูกหยุด. เพื่อการดำเนินการอย่างถูกต้อง the parameter นี้ต้องน้อยกว่าหรือ
                                    เท่ากับ the portSUPPRESS_TICKS_AND_SLEEP() parameter.

Returns:

     None.

Example usage:

ตัวอย่างแสดงการเรียกที่ถูกทำไปยังฟังชั่นต่างๆ. มีเพียง vTaskStepTick() เท่านั้นที่เป็นส่วนหนึ่งของ the FreeRTOS API. ฟังก์ชันอื่นๆ เป็นฟังก์ชันเฉพาะสำหรับ the clocks และ power saving modes มีให้ใช้ประโยชน์บน the hardware ที่ใช้, และดังนั้น, ต้องถูกจัดให้มีโดย the application writer.

(ตัวอย่างโค้ดดูในลิ้งค์เอานะครับ)


tha

https://www.freertos.org/xTaskCatchUpTicks.html

xTaskCatchUpTicks
[RTOS Kernel Control]

task.h 

BaseType_t xTaskCatchUpTicks( TickType_t xTicksToCatchUp );

แก้ไข the tick count value หลังจาก the application code ระงับ interrupts ที่ปิดการใช้งานเป็นระยะเวลาที่ยืดออกไป. ฟังชั่นนี้คล้ายกันกับ vTaskStepTick(), อย่างไรก็ตาม, ไม่เหมือน vTaskStepTick(), ฟังชั่นนี้อาจย้าย the tick count ไปข้างหน้าผ่านเวลาที่ซึ่ง a task ควรถูกเอาออกจาก the blocked state. นั่นหมายความว่า xTaskCatchUpTicks() อาจเอา tasks ออกจาก the blocked state.

Parameters:

     xTicksToCatchUp      จำนวนของ tick interrupts ที่ถูกพลาดไปเนื่องจาก interrupts ที่กำลังถูกปิดการใช้งาน. ค่าของมันไม่ถูกคำนวนโดยอัตโนมัติ, ดังนั้นต้องถูก
                                          คำนวนโดย the application writer.

Returns:

     pdTRUE ถ้าการย้าย the tick count ไปข้างหน้าส่งผลให้ a task ออกจาก the blocked state และ a context switch ถูกดำเนินการ. ถ้าเป็นอย่างอื่น
     pdFALSE.

Example usage:
(ตัวอย่างโค้ดดูในลิ้งค์เอานะครับ)