Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why are RTOS coded only in c?

Tags:

java

c

rtos

Is it necessary to code RTOS in C language always? Why can't that be coded in java or some other technology..?? Is that because of the absence of pointer concept in java?

like image 949
wrapperm Avatar asked Nov 26 '22 20:11

wrapperm


2 Answers

Garbage collection is the big reason against Java being Real Time. JIT is another, but it could be overcome.

In general though, C being effectively portable assembly gives very predicable run-time performance, and that's essential for reliable real-time execution.

like image 151
TheManWithNoName Avatar answered Nov 29 '22 10:11

TheManWithNoName


Because RTOS developers, most likely, don't know C++ well enough.

C++ in Embedded Systems: Myth and Reality

Some perceive that C++ has overheads and costs that render it somehow unsuited to embedded systems programming, that it lacks the control and brevity of C, or that, while it may be suited to some niche applications, it will never displace C as the language of choice for embedded systems.

These perceptions are wrong. Where compilers and other tools are adequate, C++ is always preferable to C as an implementation language for embedded systems. While doing everything that C does, it offers greater opportunities for expression, encapsulation, re-use, and it even allows size and speed improvements that are impractical in C.

> Why, then, do these perceptions persist? The main reason is that when people form their opinions, they know a lot more about C than about C++. They have read some books, written some code, and are competent at using the features of C++, but they lack the knowledge of what is happening under the hood, the familiarity that allows one to visualize the disassembly while typing source or even while formulating a design.

Guidelines for using C++ as an alternative to C in embedded designs

Embedded software applications are most commonly written in C. For many years, C++ has been seen as the natural successor and has found greater acceptance, but the increase in its usage has been much slower than anticipated.

There are a number of reasons for this. Firstly, embedded developers are quite conservative and prefer to use solutions that are proven rather than novel " "if it ain't broke, don't fix it".

There is also the lesson of experience. Many developers have attempted to use C++ for embedded applications and failed. Such failures may sometimes be attributed to shortcomings in development tools, but most often it is the inappropriate use of the language " treating an embedded system like a desktop computer " that is to blame.

Limitations of C Although C is widely used, it has limitations, as it was not designed for embedded applications or for projects of a scale that is now commonplace. Key limitations include:

1) C is extremely powerful and flexible and can therefore be dangerous.(It has low level capabilities - which are useful for embedded " but also represent many pitfalls for the unwary.)

2) Programmers need to be very methodical and disciplined

3) Programmers need to understand how the program behaves at low and high levels (large projects are thus hard to maintain)

4) Programmers need an expert knowledge of the application

However, C++ has powerful object oriented capabilities which can help significantly with addressing the limitations of C:

1) it encapsulates and hides areas of high expertise from non-experts into "objects;" (A test case will demonstrate the encapsulation of expertise later in Part 2 in this series).

2) Objects can be used intuitively by non-experts to implement conceptual designs at a high-level

like image 31
Özgür Avatar answered Nov 29 '22 09:11

Özgür