views:

348

answers:

4

Hi,

Can anyone help me on design patterns commonly used for RTOS?
In VXworks, which pattern is more preferable?

A: 

It depends on what you are hoping to achieve? What is the problem you are trying to solve?

IntelliChick
+5  A: 

As Mike DeSimone commented, way too generic. However, here are couple things to keep in mind for a RTOS (not just VxWorks).

  1. Avoid doing too much in the ISR. If possible pass on some of the processing to a waiting task.
  2. Keep multithreading optimal. Too much and you have context switching overhead. Too little and your problem solution may be complicated.
Sid H
+1. The first is indeed a design pattern for RTOS'es but also other OS drivers. Someone should come up with a good name and a proper pattern description. (i.e. When do you need it, what do you do precisely, etc)
MSalters
The first item is called "deferred service routine" in many OSes.
Emile Cormier
eCos calls them the Interrupt Service Routine and the Deferred Service Routine. Linux calls then the top half and bottom half, IIRC. But these aren't patterns for RTOSs... these are patterns for *drivers.*
Mike DeSimone
It is also referred to as "segmented interrupt architecture".
Clifford
+4  A: 

Can we ignore the second sentence in your question? It is meaningless, and perhaps points to a misunderstanding of design patterns. The first part is interesting however. That said, I would generalise it to cover real-time systems rather than RTOS.

Many of the most familiar patterns are mechanistic, but in real-time systems higher-level architectural patterns are also important.

Bruce Powell Douglass is probably the foremost author on the subject of patterns for real time systems. If you want a flavour of what he has to say on the subject then read this article on Embedded.com (it is part three of a series of three; be sure to read the first two as well, since they also touch on the subject, (1) (2)). You could also do worst than to visit Embedded.com and enter "design patterns" into the search box, there are a number of articles on specific patterns and general articles on the subject.

While I think you are being far to specific in requesting patterns for "RTOS(VxWorks)", patterns I have used specifically with VxWorks are the Facade and Adapter patterns. Partly to provide an OO API, and also to provide a level of RTOS agnostic abstraction. The resulting classes were then implemented for Segger emBOS (to allow us to run a smaller, lower cost, royalty free RTOS), and both Windows and Linux to allow test, debug and simulation of the code in a richer environment with more powerful tools.

A non-exhaustive list of many patterns is provided on Wikipedia, many of which will be applicable to real-time systems. The listed concurrency patterns are most obviously relevant.

Clifford
+1  A: 

Another important aspect is keeping the RTOS predictable and understandable for the user. Typically you see fixed-priority schedulers that do not try to be fair or adaptive, but rather do exactly as told and if you mess up with priorities and starve some task, so be it. Time to complete kernel operations tend to be short and predictable, often documented with their worst-case execution times.

jakobengblom2