Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How does a VxWorks scheduler get executed?

Would like to know how the scheduler gets called so that it can switch tasks. As in even if its preemptive scheduling or round robin scheduling - the scheduler should come in to picture to do any kind of task switching. Supposing a low priority task has an infinite loop - when does the scheduler intervene and switch to a higher priority task?

Query is: 1. Who calls the scheduler? [in VxWorks] 2. If it gets called at regular intervals - how is that mechanism implemented?

Thanks in advance.

--Ashwin

like image 456
Ashwin Avatar asked Jun 08 '10 06:06

Ashwin


People also ask

Is VxWorks preemptive?

VxWorks uses a priority based preemptive round-robin scheduling algorithm. Each task have a priority level between 0 and 255 where 0 is the highest priority and 255 the lowest priority.

Is Task Priority Levels in VxWorks?

VxWorks has 256 priority levels (0 is highest, 255 is lowest). At any given time, the highest priority task runs on the CPU. Each priority level conceptually has a queue where multiple tasks queue up for execution. We have 3 tasks at the same priority A, B, C.

What is task spawn VxWorks?

DESCRIPTION. This routine creates and activates a new task with a specified priority and options and returns a system-assigned ID.


1 Answers

The simple answer is that vxWorks takes control through a hardware interrupt from the system timer that occurs continually at fixed intervals while the system is running.

Here's more detail:

When vxWorks starts, it configures your hardware to generate a timer interrupt every n milliseconds, where n is often 10 but completely depends on your hardware. The timer interval is generally set up by vxWorks in your Board Support Package (BSP) when it starts.

Every time the timer fires an interrupt, the system starts executing the timer interrupt handler. The timer interrupt handler is part of vxWorks, so now vxWorks has control. The first thing it does is save the CPU state (such as registers) into the Task Control Block (TCB) of the currently running task.

Then eventually vxWorks runs the scheduler to determine who runs next. To run a task, vxWorks copies the state of the task from its TCB into the machine registers, and after it does that the task has control of the CPU.

Bonus info:

vxWorks provides hooks into the task switching logic so you can have a function get called whenever your task gets preempted.

like image 159
indiv Avatar answered Sep 30 '22 14:09

indiv