Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What makes VxWorks so deterministic and fast?

I worked on VxWorks 5.5 long time back and it was the best experience working on world's best real time OS. Since then I never got a chance to work on it again. But, a question keeps popping to me, what makes is so fast and deterministic?

I have not been able to find many references for this question via Google.

So, I just tried thinking what makes a regular OS non-deterministic:

  1. Memory allocation/de-allocation:- Wiki says RTOS use fixed size blocks, so that these blocks can be directly indexed, but this will cause internal fragmentation and I am sure this is something not at all desirable on mission critical systems where the memory is already limited.

  2. Paging/segmentation:- Its kind of linked to Point 1

  3. Interrupt Handling:- Not sure how VxWorks implements it, as this is something VxWorks handles very well

  4. Context switching:- I believe in VxWorks 5.5 all the processes used to execute in kernel address space, so context switching used to involve just saving register values and nothing about PCB(process control block), but still I am not 100% sure

  5. Process scheduling algorithms:- If Windows implements preemptive scheduling (priority/round robin) then will process scheduling be as fast as in VxWorks? I dont think so. So, how does VxWorks handle scheduling?

Please correct my understanding wherever required.

like image 628
Piyush Kansal Avatar asked Jan 10 '12 08:01

Piyush Kansal


1 Answers

I believe the following would account for lots of the difference:

No Paging/Swapping

A deterministic RTOS simply can't swap memory pages to disk. This would kill the determinism, since at any moment you could have to swap memory in or out. vxWorks requires that your application fit entirely in RAM

No Processes

In vxWorks 5.5, there are tasks, but no process like Windows or Linux. The tasks are more akin to threads and switching context is a relatively inexpensive operation. In Linux/Windows, switching process is quite expensive.

Note that in vxWorks 6.x, a process model was introduced, which increases some overhead, but mainly related to transitioning from User mode to Supervisor mode. The task switching time is not necessarily directly affected by the new model.

Fixed Priority

In vxWorks, the task priorities are set by the developer and are system wide. The highest priority task at any given time will be the one running. You can thus design your system to ensure that the tasks with the tightest deadline always executes before others.

In Linux/Windows, generally speaking, while you have some control over the priority of processes, the scheduler will eventually let lower priority processes run even if higher priority process are still active.

like image 190
Benoit Avatar answered Oct 03 '22 10:10

Benoit