CHANGE PRIORITY OF A TASK Description This function allows you to change the priority of a task dynamically Note that the new priority MUST be available Arguments oldp is the
The function OSTaskChangePrio allows changing the priority of a task dynamically. It takes the old priority and the new priority as arguments, and returns an error code indicating the success or failure of the operation.
The function first checks if the new priority already exists, and returns an error if it does. It then checks if the task with the specified old priority exists, and returns an error if it does not or if it is assigned to a mutex PIP.
The function then computes the new TCB fields and removes the TCB from the old priority, and places a pointer to the TCB at the new priority. If the task is ready, it makes it not ready and adds it to the new priority ready list. If the task is waiting on an event, it removes it from the old priority wait list and adds it to the new priority wait list.
Finally, the function sets the new task priority and TCB fields, and schedules the new highest priority task if the kernel is running. The function returns an error code indicating the success or failure of the operation.
原文地址: https://www.cveoy.top/t/topic/bjpX 著作权归作者所有。请勿转载和采集!