Q:

How does vxWorks deal with two tasks at the same priority?

We have two tasks (T1 and T2) in our vxWorks embedded system that have the same priority (110).
How does the regular vxWorks scheduler deal with this if both tasks are ready to run?
Which task executes first?

A:

The task that will run first is the task that is spawned first as realized by the VxWorks scheduler task. VxWorks uses priority-based scheduling by default. So in your case, since T1 and T2 have the same priority, whichever one gets the CPU first will continue to run indefinitely until it is explicitly blocked (using taskSuspend or taskDelay), at which time the other READY task will execute until it is blocked, and so on. This ought to be controlled by semaphores or mutexes (mutices?)
The main problem with priority-based scheduling is illuminated by this exact problem. How do we determine how long to let these tasks run? The fact that they have the same priority complicates things. Another concern is that VxWorks tasks that have high priority (lower number means higher priority) can preempt your application which you must be prepared for in your code. These problems can be solved by using round-robin scheduling. The additional problems posed by round-robin scheduling and the solutions are all described here.

