OsResultE OsTaskSetPriority( OsHndlT task, UInt8T priority );
Function OsTaskSetPriority() may be called by a client application to change the priority of a task. The first argument is a handle to the task, obtained from OsNewTask(). If this task handle is invalid, no action is taken and the function returns OsResult_INVALID_TASK. The second argument must be a value from the enumeration OsPriorE and represents the new priority to be assigned to the task (high, medium, low or idle). This is the priority at which the task will be queued the next time it becomes ready. If the priority is out of range, it is quietly fixed up to the lowest (idle) priority.
The example below shows a task having its priority elevated to HIGH. The result returned by the function is not checked, which means that the author is confident that variable task contains a valid task handle.
OsTaskSetPriority( task, OsPrior_HIGH );
This is an advanced function and many applications will not use it. This function can be called when a task is already queued, but this does not result in the task being re-queued at the new priority and is perhaps best avoided. If task handles are assigned as constants at compile time rather than obtained at run time by calling OsNewTask(), function OsTaskSetPriority() should be used to set task priorities. In most cases, they will not subsequently be changed.