YouTube Icon

Interview Questions.

Top 50 Embedded Systems Interview Questions - Jul 23, 2022

fluid

Top 50 Embedded Systems Interview Questions

Q1. Advantages And Disadvantages Of Using Macro And Inline Functions?

Advantage: Macros and Inline functions are green than calling a everyday function. The times spend in calling the characteristic is stored in case of macros and inline functions as these are included directly into the code.

Disadvantage: Macros and inline features elevated the dimensions of executable code.

Q2. Can A Pointer Be Volatile ?

Yes, although this isn't always very commonplace. An example is whilst an interrupt service ordinary modifies a pointer to a buffer.

Q3. What Is Mutex?

Mutual exclusion (frequently abbreviated to mutex) algorithms are utilized in concurrent programming to avoid the simultaneous use of a commonplace useful resource, consisting of a global variable, by way of portions of pc code known as important sections.

Q4. What Is A Memory Leak? What Is A Segmentation Fault?

The reminiscence leak refers back to the uncleared memory may additionally builds up throughout lifetime of the procedure. When it comes to a big fee machine stalls its execution due to unavailability of the reminiscence. The segmentation fault then again refers to situation whilst our software attempts to access a memory space that has already been freed up.

Q5. What Is The Difference Between Fifo And The Memory?

Fifo(First In Last Out) is a memory shape wherein records may be stored and retrieved (within the order of its entry most effective). This is a queue,wheras Memory is a storage device which can maintain facts dynamically or at any desired places and may be retrieved in any order.

Q6. Accessing Fixed Memory Locations?

Embedded systems are regularly characterized by way of requiring the programmer to get admission to a particular reminiscence area. On a sure task it is required to set an integer variable on the absolute cope with 0x67a9 to the fee 0xaa5@The compiler is a natural ANSI compiler. Write code to perform this assignment.

This hassle checks whether or not you know that it's miles criminal to typecast an integer to a pointer as a way to access an absolute area. The specific syntax varies depending upon one's fashion. However, I could commonly be searching out something like this:

  int *ptr;  ptr = (int *)0x67a9;  *ptr = 0xaa55;    

A more difficult to understand approach is:

  *(int * const)(0x67a9) = 0xaa55;

Q7. Which Is The Best Way To Write Loops?

The nice way is to write down rely down loops and compiler can generate better system code for it than the matter up loops. In remember down at loop termination, it needs to generate one preparation (SUBS), which subtracts in addition to check the 0 flag, however in depend up case it has to feature and evaluate with a consistent, which takes two instructions.

Q8. How Are Variables Mapped Across To The Various Memories By The C Compiler?

The compiler maintains the image desk which has the related data of all the variable names in conjunction with the duration of the allotted space, the access unit duration for the pointer (type of pointer) and the starting deal with of the reminiscence area.

Q9. Can A Volatile Be Constant?

Volatile const a;

Yes it can be, it me that, it could be adjustments by hardware kingdom change, but its study handiest sign up in hardware, so code should not attempt to adjust it.

Q10. What Is Isr? Can They Be Passed Any Parameter And Can They Return A Value?

ISR refers back to the Interrupt Service Routines. These are techniques stored at particular memory addresses which might be known as while sure type of interrupt happens. The ISRs can't go back a value and that they can not be exceeded any parameters.

Q11. Explain Can We Have Constant Volatile Variable?

Const and unstable key phrases must no longer be used collectively due to the fact each are opposite in nature. A variable is said as "const" me it's cost isn't always capable of be modified but if it's miles declared as "Volatile" then it isn't below manipulate.

Q12. How Is Function Itoa() Written In C?

  #encompass<stdlib.H>  #encompass<stdio.H>  int major()    int n = 6789;  char p[20];  itoa(n,s,10);  printf("n=%d,s=%s",n,s);  go back zero;   

Q13. What Is The Size Of The Int, Char And Float Data Types?

The length of the char and int are usually dependent on the underlying running machine or firmware. This is restrained to the quantity of address strains in the deal with bus. The int commonly takes up a value of two bytes or four bytes. The char can soak up a area of one or 2 bytes. The go with the flow data kind takes up a value of four bytes.

Q14. Explain The Properties Of A Object Oriented Programming Language.

Encapsulation: The facts that are related to the specific object are contained in the item structure and hidden from the other entities of the environment.  

Polymorphism: The mechanism through which the equal pointer can seek advice from exclusive kinds of gadgets, that are essentially connected with the aid of some customary commonality.

 Abstraction: Hiding the statistics and implementation info from the real objects. The framework of reference remains present to be used by the other objects.

 Inheritance: The way to take out the commonplace features and feature them as separate object entities best to be reused by using the alternative items in a modular fashion.

Q15. What Is The Order Of Calling For The Constructors And Destructors In Case Of Objects Of Inherited Classes?

The constructors are called with base magnificence first order and the destructors are known as in the infant first order. That is, the if we've got 2 ranges of inheritance A (base)-> B (inherit 1)-> C (inherit 2) then the constructor A is called first accompanied through B and C. The C destructor is referred to as first observed by means of B and A.

Q16. What Is Plc System?

Programming logical control system.

Q17. What Is A 'unstable' Variable?

Volatile is a keyword to specify the compiler that this variable cost can exchange any time, so compiler must usually study its fee from its address, and not to use temporary registers to store its fee and use in later a part of the code. This is specifically crucial to address the reminiscence mapped registers that are mapped as some variables or systems in embedded systems, which include hardware status registers and many others, whose value can be changed anytime, relying at the hardware kingdom.

Examples of volatile variables are,

• Hardware registers in peripherals (for example, fame registers)

• Non-computerized variables referenced within an interrupt service habitual

• Variables shared via more than one responsibilities in a multi-threaded utility

Q18. What Is Meant By A Forward Reference In C?

The ahead reference refers back to the case when we point an address area of a smaller data kind with a pointer of a bigger statistics kind. This may be pictured as allocating reminiscence in unmarried bytes and getting access to it with integer pointer as chunks of 4.

Q19. Which Is Better A Char, Short Or Int Type For Optimization?

Where possible, it's miles satisfactory to avoid the usage of char and quick as nearby variables. For the types char and brief the compiler needs to lessen the dimensions of the nearby variable to eight or sixteen bits after each task. This is called signal-extending for signed variables and zero extending for unsigned variables. It is applied via transferring the sign up left by using 24 or 16 bits, followed by using a signed or unsigned shift proper with the aid of the identical amount, taking two commands (zero-extension of an unsigned char takes one training).

These shifts may be avoided by way of the use of int and unsigned int for neighborhood variables. This is specially important for calculations which first load data into local variables after which technique the records in the local variables. Even if statistics is input and output as 8- or 16-bit portions, it's far worth thinking about processing them as 32bit quantities

Q20. Difference In Inline Functions And Macro

 Macro is elevated by preprocessor and inline characteristic are expanded by using compiler.

 Expressions exceeded as arguments to inline capabilities are evaluated handiest once while _expression passed as argument to inline features are evaluated extra than once.

More over inline functions are used to triumph over the overhead of characteristic calls.

Macros are used to preserve the clarity and smooth renovation of the code.

Q21. What Is Interrupt Latency?

Interrupt latency refers to the amount of time between when an interrupt is brought about and when the interrupt is seen with the aid of software program.

Q22. What Does Malloc Do? What Will Happen If We Have A Statement Like Malloc(sizeof(zero));

Malloc is the characteristic this is used for dynamically allocating reminiscence to the different variables. The malloc returns a reminiscence pointer of void type (void *). The assertion malloc(sizeof(0)) returns a legitimate integer pointer because sizeof(0) represents the scale of memory taken up by the integer cost of @The memory allotted through reminiscence isn't always robotically wiped clean up by the compiler after execution of the functions and must be wiped clean up through the programmer using the free() feature.

Q23. What Is Difference Between Using A Macro And Inline Function?

The macro are just symbolic representations and can't incorporate statistics kind differentiations inside the parameters that we provide. The inline functions will have the information sorts too defined as a part of them. The disadvantage in the use of both is that the inclusion of situation tests may also cause boom in code area if the characteristic is known as often.

Q24. What Type Of Registers Contains An (intel) Cpu?

Special feature registers like accumulator, Program controller(PC),information pointer(DPTR),TMOD and TCON (timing registers),three check in banks with r0 to r7,Bit addressable registers like B.

Q25. Explain Can Microcontroller Work Independently?

Obviously, it may work independently. But to peer the output we need positive output devices like LED, Buzzer may be linked to test its functionality. Without the assist of any o/p tool linked we will check the functionality of Microcontroller.

Q26. What Is Semaphore?

In pc science, a semaphore is a included variable or summary statistics type which constitutes the traditional method for restricting get admission to to shared assets which include shared reminiscence in a parallel programming surroundings. A counting semaphore is a counter for a fixed of to be had sources, in place of a locked/unlocked flag of a unmarried resource.

Q27. What Is The Use Of Having The Const Qualifier?

The const qualifier identifies a specific parameter or variable as read-handiest attribute to the characteristic or to the complete software. This can come in reachable whilst we are dealing with static information inner function and in a software.

Q28. Explain What Happens When Recursion Functions Are Declared Inline?

Inline features assets says each time it will known as, it'll replica the complete definition of that function. Recursive function declared as inline creates the load at the compilers execution. The length of the stack may also/might not be overflow if the characteristic size is massive.

Q29. What Do You Mean By Interrupt Latency?

Interrupt latency refers back to the time taken for the machine to start the handler for the specific interrupt. The time from the time of arrival of interrupt to the time it is being treated.

Q30. What Is Difference Between Micro Processor & Micro Controller?

 Microprocessor is a manager of the sources (I/O, Memory) which lie out-facet of its architecture.

Micro-controllers have I/O, Memory etc. Built into it and in particular designed for Control applications.

Q31. Why Cannot Arrays Be Passed By Values To Functions?

When a array is exceeded to a feature, the array is internally modified to a ‘pointer’. And pointers are always surpassed with the aid of reference.

Q32. Write A Constant Time Consuming Statement Lot Finding Out If A Given Number Is A Power Of 2?

If n is the given variety, then the expression (n & (n-1)) = 0 gives the logical output depicting if it is a electricity of two or now not, if (n & (n-1) == zero) printf (“The given variety is a strength of 2”);

Q33. Scope Of Static Variables?

Scope of static variable is in the file if it's far static international. Scope of static variable is within the characteristic if variable is declared neighborhood to a characteristic. But the existence time is at some stage in this system.

Q34. What Are Recursive Functions? Can We Make Them Inline?

The recursive capabilities check with the capabilities which make calls to itself earlier than giving out the final result. These may be declared as in-line capabilities and the compiler will allocate the memory area meant for the primary call of the function.

Q35. Explain Can Structures Be Passed To The Functions By Value?

Yes systems may be surpassed to functions by means of cost. Though passing by way of value has two dangers:

1) The charges through the calling function aren't pondered.

2) It’s slower than the skip with the aid of reference feature name.

Q36. Explain What Will This Return Malloc(sizeof(-10))?

It will go back a four byte deal with fee.

Because -10 is a signed integer(varies from compiler to compiler).

Q37. What Are The Advantages And Disadvantages Of Using Macro And Inline Functions?

Advantage:

Macros and Inline features are efficient than calling a everyday feature. The times spend in calling the feature is saved in case of macros and inline functions as those are included immediately into the code.

Disadvantage:

Macros and inline features expanded the scale of executable code.

Q38. Why Do We Need A Infinite Loop In Embedded Systems Development? What Are The Different Ways By Which You Can Code In A Infinite Loop?

The infinite loops are coded in to present a delay or sleep to the program execution for a specific amount of clock ticks. They can be applied as:

  whilst(;;);   for();   (or)   Loop:   goto Loop;

Q39. Explain What Is Interrupt Latency? How Can We Reduce It?

Interrupt latency is the time required to go back from the interrupt provider habitual after tackling a specific interrupt. We can reduce it via writing smaller ISR routines.

Q40. What Is A Semaphore? What Are The Different Types Of Semaphore?

The semaphore is an abstract records shop that is used to manipulate useful resource accesses throughout the diverse threads of execution or across different strategies. There are two varieties of semaphores:

• The binary semaphore that may take most effective zero,1 values. (used while there is rivalry for a unmarried aid entity). 

• The counting semaphore that can take incremental values to certain limit (used whilst number of assets is restricted).

Q41. Explain What Is Forward Reference W.R.T. Pointers In C?

Pointer use's to reference to fee a into int a=10 to reminiscence upload this cost and 10 is add p cost introduced this information in memory vicinity for p.

Q42. What Is Pass By Value And Pass By Reference? How Are Structure Passed As Arguments?

The parameter to a feature may be a duplicate of a value that is represented by way of variable or can be a reference to a reminiscence space that stores price of variable. The former is referred to as pass with the aid of cost and the latter is called pass through reference. The distinction is that once parameters are handed via fee the modifications made to the variable value inside the function isn't always meditated in the caller feature, however while surpassed as reference adjustments are contemplated out of doors the called function. The structures are constantly passed by way of reference.

Q43. What Is A Pure Function In Arm Terminology?

Pure capabilities are the ones which return a end result which relies upon only on their arguments. They can be notion of as mathematical features: they continually return the identical result if the arguments are the same. To inform the compiler that a function is pure, use the special assertion keyword __pure.

  __pure int square(int x)        go back x * x;  

Q44. What Is Concurrency? Explain With Example Deadlock And Starvation.

Concurrency is nothing however execution of different tractions simultaneously on one unmarried useful resource.

Dead lock :

A institution of threads are waiting for sources held by others in the institution. None of them will ever make progress.

Example :

An example of a impasse which may arise in database merchandise is the following. Client applications the use of the database can also require extraordinary get entry to to a table, and to be able to benefit distinct get right of entry to they ask for a lock. If one purchaser utility holds a lock on a desk and attempts to obtain the lock on a 2d desk that is already held via a 2d patron utility, this could lead to deadlock if the second application then tries to attain the lock that is held via the primary utility.

Starvation :

A thread can also wait indefinitely because other threads keep coming in and getting the requested sources earlier than this thread does. Note that resource is being actively used and the thread will stop ready if different threads forestall coming in.

Example :

High priority thread:

  at the same time as(1);

if the gadget is precedence primarily based gadget then low priority thread never gets a hazard.

 

Q45. Dma Deals With Which Address (physical/digital Addresses)?

DMA offers with Physical addresses.

Only whilst CPU accesses addresses it refers to MMU(Memory Management Unit) and MMU converts the Physical address to Virtual deal with.

But, DMA controller is a device which without delay drives the information and address bus for the duration of information trfer. So, it's miles in simple terms Physical deal with. (It by no means wishes to undergo MMU & Virtual addresses).

That is why whilst writing the device drivers, the bodily cope with of the statistics buffer needs to be assigned to the DMA.

Q46. What Is The Difference Between Embedded Systems And The System In Which Rtos Is Running?

Embedded system is just combination of s/w and h/w this is some embedded device can also have os some may not and rtos is an os.

                                                                  OR

Embedded machine can include RTOS and cannot consist of additionally. It relies upon on the requirement. If the device wishes to serve most effective occasion sequentially, there is no want of RTOS. If the gadget needs the parallel execution of events then we need RTOS.

Q47. What Is Loop Unrolling?

Small loops can be unrolled for higher overall performance, with the drawback of accelerated codesize. When a loop is unrolled, a loop counter desires to be up to date much less often and fewer branches are carried out. If the loop iterates just a few instances, it may be absolutely unrolled, in order that the loop overhead completely disappears.

  Int CountBitOne(uint n)           int bits = 0;      while (n != zero)                if (n & 1) bits++;          n >> = 1;          return bits;       int CountBitOne(uint n)       int bits = zero;      even as (n != zero)            if (n & 1) bits++;      if (n & 2) bits++;      if (n & 4) bits++;      if (n & eight) bits++;      n >> = 4;          go back bits;    

Q48. What Is The Role Of Segment Register?

In the x86 processor structure, memory addresses are laid out in two components known as the section and the offset. One generally thinks of the segment as specifying the start of a block of reminiscence allotted through the gadget and the offset as an index into it. Segment values are saved in the phase registers. There are four or extra phase registers: CS includes the segment of the cutting-edge instruction (IP is the offset), SS incorporates the stack segment (SP is the offset), DS is the segment used by default for maximum records operations, ES (and, in greater latest processors, FS and GS) is an extra section check in. Most memory operations receive a segment override prefix that allows use of a phase sign in aside from the default one.

Q49. What Is Dirac Delta Function And Its Fourier Trform And Its Importance?

Dirac delta is a continuous time feature with unit vicinity and countless amplitude at t=0 the fourier trform of dirac delta is @

the usage of dirac delta as an enter to the device, we will get the gadget reaction. It is used to look at the behavior of the circuit.

We are able to use this device conduct to find the output for any input.

Q50. Explain What Are The five Different Types Of Inheritance Relationship?

5 level kinds are as below:

unmarried: B derived from A.

Multilevel: derived from B and B derived from A.

A couple of: C derived from A and B.

Hierarchical: B derived from A and C derived from A.

Hybrid: combination of above sorts.




CFG