0

I have experience with several RTOS (pSOS, VxWorks, QNX) however I'm new to MicroC/OS II (ucos ii). I see that something unique about ucos ii is instead of having a unique ID for tasks it uses the priority to uniquely identify tasks and that all tasks must be at different priorities and thus round robin scheduling is not supported. That much I understand. Here's the question:

If I change the priority of a task with OSTaskChangePrio() doesn't that cause problems for any code or other tasks that had stored the priority (task ID) of the task that just changed its priority. In effect changing priority changes the identity of the task. How is this not a problem?

JonN
  • 2,498
  • 5
  • 33
  • 49

2 Answers2

0

That function checks if some task with requested priority/ID already exists and if so it returns an error. Therefore in the case you want to change priority of your task you shall leave appropriate place in tasks table. ucosii can manage up to 255 tasks, but in every project you shall specify OS_LOWEST_PRIO value. This way you limit the amount of the tasks available. ucosii is not like psos or vxworks - it is more like nucleus or threadx - very thin OS.

0

You wouldn't want to change the priority of your tasks unless you are implementing something like a dynamic scheduling algorithm or may be a resource allocation algorithm for your RTOS. In such cases, one does not care about the identity of the task as priority. One would only care about which task needs to run at this moment based on factors such as the task's deadline.

You are correct. In case you do use OSTaskChangePrio, you can no longer identify tasks based on just task priority.

  • Just one example, I might want to have the task that starts up other tasks reduce it's priority when it's done. Allowing a task to effectively change its Task ID means I can't depend on using that as a way to identify the task. I also found it unclear when ucos ii does priority inversion does it actually change the task id (priority) as seen by other tasks. That is if I try to use the original task id(priority) while priority inversion is occurring to identify that task does the OS call fail because no task has that task ID (priority) at that moment? – JonN Dec 27 '16 at 01:49