Most Asked Embedded Systems Interview Questions and Answers
What is difference between using a macro and a in line function?
The macro are just symbolic representations and cannot contain data type differentiations within the parameters that we give. The in line functions can have the data types too defined as a part of them. The disadvantage in using both is that the inclusion of condition checks may lead to increase in code space if the function is called many times.
What is the volatile keyword used for?
The volatile keyword is used to represent variables that point to memory in other mapped devices. In such a case the value of the variable can be changed outside of a program. The compiler does not do additional optimizations to the code if there is volatile keyword.
What are hard and soft Real time systems?
The hard real time systems are the once that depend on the output very strictly on time. Any late response or delay cannot be tolerated and will always be considered a failure. The soft real time systems on the other are not very rigid as the hard real time systems. The performance of the system degrades with the lateness of response, but it is bearable and can be optimized to a certain level for reuse of the result.
What is a semaphore? what are the different types of semaphore?
The semaphore is an abstract data store that is used to control resource accesses across the various threads of execution or across different processes. There are two types of semaphores:
• The binary semaphore which can take only 0,1 values. (used when there is contention for a single resource entity)
• The counting semaphore which can take incremental values to certain limit (used when number of resources is limited).
Write a constant time consuming statement lot finding out If a given number Is a power of 2?
If n is the given number, then the expression (n & (n-1)) = 0 gives the logical output depicting if it is a power of 2 or not, if (n & (n-1) == 0) printf (“The given number is a power of 2”);
What are recursive functions? Can we make them in line?
The recursive functions refer to the functions which make calls to itself before giving out the final result. These can be declared as in-line functions and the compiler will allocate the memory space intended for the first call of the function.
What is the size of the int, char and float data types?
The size of the char and int are always dependent on the underlying operating system or firmware. This is limited to the number of address lines in the address bus.
The int usually takes up a value of 2 bytes or 4 bytes. The char can take up a space of 1 or 2 bytes. The float data type takes up a value of 4 bytes.
What does malloc do? What will happen if we have a statement like malloc(sizeof(0));
Malloc is the function that is used for dynamically allocating memory to the different variables. The malloc returns a memory pointer of void type (void *). The statement malloc(sizeof(0)) returns a valid integer pointer because sizeof(0) represents the size of memory taken up by the integer value of 0. The memory allocated by memory is not automatically cleaned up by the compiler after execution of the functions and should be cleaned up by the programmer using the free() function.
What is meant by a forward reference in C?
The forward reference refers to the case when we point an address space of a smaller data type with a pointer of a bigger data type This can be pictured as allocating memory in single bytes and accessing it with integer pointer as chunks of 4.
What is the order of calling for the constructors and destructors in case of objects of inherited classes?
The constructors are called with base class first order and the destructors are called in the child first order. That is, the if we have 2 levels of inheritance A (base)-> B (inherit 1)-> C (inherit 2) then the constructor A is called first followed by B and C. The C destructor is called first followed by B and A.
Explain the properties of a Object oriented programming language.
• Encapsulation: The data that are related to the specific object are contained inside the object structure and hidden from the other entities of the environment
• Polymorphism: The mechanism by which the same pointer can refer to different types of objects, which are basically linked by some generic commonality.
• Abstraction: Hiding the data and implementation details from the real objects. The framework of reference is still present to be used by the other objects.
• Inheritance: The way to take out the common features and have them as separate object entities only to be reused by the other objects in a modular fashion.