What makes VxWorks so deterministic and fast?
Asked Answered
L

1

10

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.

Lomond answered 10/1, 2012 at 8:28 Comment(0)
L
13

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.

Lavernalaverne answered 12/1, 2012 at 23:19 Comment(6)
I agree with most of your points, but then how does it take care of invalid memory accesses. Does it enforces a construct that before a task starts, it has to request for the amount of memory it is going to use? Bcoz that is the only way, VxWorks can set the boundary regions of a task.Lomond
I 5.5 there is no "invalid memory access" unless the system really accesses an address where nothing is mapped. Then an exception handler is called. Tasks have access to the entire memory. Even other tasks' or even kernel data structures. 6.x Process model limits memory access to the process space using the MMU.Lavernalaverne
The swapping part may de facto be the case for "big" RTOS but it is by no means a necessity. A RTOS simply must guarantee the deadlines of your processes -- and as long as it does not violate this rule, it is real time. If you critical process must be run within 5 minutes and swapping it back in can be guaranteed to take at most 3 minutes and it takes 1 minute to run at worst you are fine.Theda
@Benoit, your last paragraph is incorrect. In Linux, you can use static scheduling priority (see SCHED_FIFO policy) to prevent lower priority processes from running as long as higher priority processes need to run. This functionality is very old.Tineid
@Theda What you say is true, but I would contend that most RTOS deadlines are seconds or less in which case, swapping is a killer.Lavernalaverne
@Lavernalaverne So does it mean there is no concept of virtual memory if there is no paging/swapping right? We have a flat memory model with everything "mapped in" already so essentially no translations needed AT ALL?Agglutination

© 2022 - 2024 — McMap. All rights reserved.