Tell me more ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there any gotcha's programming RealTime C++ applications (user space and linux drivers) on RT linux kernel compare to a std linux kernel?

The Linux RT patch applies changes to kernel scheduler, semaphores, muteces, etc, and I'm wondering if these changes are transparent to the developer? or would one need to take special care in writing such application?

share|improve this question

2 Answers

I've no experience of programming RT applications with C++: I used Ada; also, Erlang may fit. (There is also RT Java, but I have no experience of it.)

In principle, using C++ should not be a problem, given the tools for IPC (as you mentioned), fork, etc. Explicit memory management will of course be error-prone, unless (until) you master it.

RT Linux is an extension to Linux (obviously), and that is common for many RTOSs, to be extensions to non-RT, but time-sharing, OSs.

In order for the (RT) tasks to coexist with the (non-RT) processes, the RTOS takes certain measures: for example, lock the tasks in memory, or assign them higher priorities than the (non-RT) processes. The purpose is to make sure no (non-RT) process will ever block an (RT) task (thus possibly leading to its failure to meet its deadline). In the case of RT Linux, it will assign the Linux kernel the lowest priority.

RT Linux is between the Linux kernel and the hardware. The Linux kernel will be oblivious to this: it will perceive the hardware and RT Linux as one (i.e., as hardware). All hardware interrupts will be intercepted by the RT Linux kernel, and some (those relating to RT tasks) will be dealt with by the RTOS; the rest will be passed on to the ordinary Linux kernel.

RT Linux uses RT scheduling algorithms that ensure "predictable" behaviour (in RT lingo), that is, that all tasks meet their deadlines. This differs from Linux, which can't make any such guarantees. Also, RT Linux does not support virtual memory, as this (swapping back and forth) would lead to much longer context switches, and thus (possibly) unpredictable delay times. (In fact, all RT Linux tasks have full access to the hardware.)

share|improve this answer

Depends - if you actually develope kernel space drivers that use mutexes and semaphores you should give the patches a quick review. As developer that is your responsibility, no answer on a website will solve that issue.

If you are mainly developing userspace software, these changes do not affect you, as you only wrangle with the kernel interfaces, which are supposed to be stable.

Keep in mind that userspace applications are usually not recommended for strong real time requirements.

Due to the fact that most major distributions supply a RT kernel I conclude: No, nothing special beyond the RT fun is required - general keep in mind things: https://rt.wiki.kernel.org/index.php/HOWTO:_Build_an_RT-application

share|improve this answer
the RT wiki site is an excellent source of information for RT dev, tx for the link. – fduff Jan 24 at 18:59

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.