YouTube Icon

Interview Questions.

Top 100+ Embedded C Interview Questions And Answers - May 29, 2020

fluid

Top 100+ Embedded C Interview Questions And Answers

Question 1. What Is The Use Of Volatile Keyword?

Answer :

The C's unstable keyword is a qualifier that tells the compiler not to optimize while implemented to a variable. By putting forward a variable risky, we are able to inform the compiler that the price of the variable may exchange any moment from out of doors of the scope of this system. A variable have to be declared risky whenever its fee may want to exchange all at once and past the comprehension of the compiler.

In the ones cases it's far required not to optimize the code, doing so may additionally lead to erroneous result and cargo the variable every time it's far used inside the software. Volatile key-word is beneficial for memory-mapped peripheral registers, global variables modified by an interrupt carrier recurring, international variables accessed by means of multiple obligations inside a multi-threaded utility.

Question 2. Can A Variable Be Both Const And Volatile?

Answer :

The const keyword ensure that the value of the variable declared as const can not be modified. This announcement holds real in the scope of the program. The fee can nonetheless be modified via outside intervention. So, using const with unstable key-word makes ideal feel.

Embedded Systems Interview Questions
Question 3. Can A Pointer Be Volatile?

Answer :

If we see the declaration unstable int *p, it manner that the pointer itself isn't always risky and factors to an integer that is volatile. This is to tell the compiler that pointer p is pointing to an integer and the value of that integer can also trade all at once even if there may be no code indicating so inside the application.

Question four. What Is Size Of Character, Integer, Integer Pointer, Character Pointer?

Answer :

The sizeof man or woman is 1 byte.

Size of integer is four bytes.

Size of integer pointer and person is 8 bytes on 64 bit device and 4 bytes on 32 bit device.

Linux Embedded systems Tutorial
Question five. What Is Null Pointer And What Is Its Use?

Answer :

The NULL is a macro described in C. Null pointer simply way a pointer that does not factor to any legitimate location. We define a pointer to be null while we need to make certain that the pointer does not point to any valid vicinity and now not to use that pointer to exchange something. If we do not use null pointer, then we cannot affirm whether this pointer points to any legitimate vicinity or now not.

Linux Embedded systems Interview Questions
Question 6. What Is Void Pointer And What Is Its Use?

Answer :

The void pointer means that it factors to a variable that may be of any kind. Other suggestions points to a selected sort of variable whilst void pointer is a extremely universal pointer and may be pointed to any information type, be it widespread facts type(int, char etc) or user outline facts type (structure, union and many others.). We can pass any sort of pointer and reference it as a void pointer. But to dereference it, we ought to kind the void pointer to correct statistics kind.

Question 7. What Is Isr?

Answer :

An ISR(Interrupt Service Routine) is an interrupt handler, a callback subroutine that's known as whilst a interrupt is encountered.

MATLAB Tutorial MATLAB Interview Questions
Question 8. What Is Return Type Of Isr?

Answer :

ISR does no longer go back something. An ISR returns nothing because there's no caller within the code to study the back values.

Question 9. What Is Interrupt Latency?

Answer :

Interrupt latency is the time required for an ISR responds to an interrupt.

AUTOSAR Interview Questions
Question 10. How To Reduce Interrupt Latency?

Answer :

Interrupt latency may be minimized by way of writing quick ISR ordinary and through no longer delaying interrupts for extra time.

Question eleven. Can We Use Any Function Inside Isr?

Answer :

We can use characteristic inside ISR as long as that function is not invoked from different portion of the code.

PLC/Microcontrollers/Microprocessors Interview Questions
Question 12. Can We Use Printf Inside Isr?

Answer :

Printf feature in ISR isn't supported because printf characteristic isn't reentrant, thread secure and makes use of dynamic reminiscence allocation which takes numerous time and may have an effect on the velocity of an ISR up to a incredible quantity.

Embedded Systems Interview Questions
Question thirteen. Can We Put Breakpoint Inside Isr?

Answer :

Putting a breakpoint inside ISR is not a good concept due to the fact debugging will take the time and a difference of half or greater 2d will cause one of a kind conduct of hardware. To debug ISR, definitive logs are higher.

Question 14. Can Static Variables Be Declared In A Header File?

Answer :

A static variable can't be declared without defining it. A static variable may be described in the header document. But doing so, the result will be having a non-public reproduction of that variable in every supply document which incorporates the header record. So it is going to be wise not to claim a static variable in header report, except you are coping with a unique situation.

Question 15. Is Count Down To Zero Loop Better Than Count_up_loops?

Answer :

Countdown to zero loops are better. Reason behind that is that at loop termination, contrast to zero can be optimized by means of the compiler. Most processors have training for comparing to zero. So they don't want to load the loop variable and the most cost, subtract them and then evaluate to zero. That is why matter right down to 0 loop is better.

Autosys Interview Questions
Question sixteen. What Are Inline Functions?

Answer :

The ARM compilers guide inline features with the key-word __inline. These capabilities have a small definition and the characteristic frame is substituted in each call to the inline characteristic. The argument passing and stack maintenance is skipped and it consequences in faster code execution, but it increases code length, specifically if the inline feature is big or one inline feature is used often.

Question 17. Can Include Files Be Nested?

Answer :

Yes. Include files may be nested any range of times. But you have to ensure which you aren't inclusive of the same file two times. There is no limit to what number of header files that can be included. But the wide variety can be compiler dependent, on the grounds that which includes a couple of header files may additionally reason your laptop to expire of stack reminiscence.

8051 Microcontroller Interview Questions
Question 18. What Are The Uses Of The Keyword Static?

Answer :

Static key-word may be used with variables as well as capabilities. A variable declared static could be of static storage magnificence and within a feature, it maintains its fee among calls to that characteristic. A variable declared as static within a file, scope of that variable might be inside that document, however it can not be accessed by way of different documents.

Functions declared static inside a module can be accessed through other capabilities inside that module. That is, the scope of the characteristic is localized to the module inside which it is declared.

Linux Embedded systems Interview Questions
Question 19. What Are The Uses Of The Keyword Volatile?

Answer :

Volatile keyword is used to save you compiler to optimize a variable that can alternate all of sudden beyond compiler's comprehension. Suppose, we've a variable which can be changed from scope out of the program, say by way of a signal, we do no longer need the compiler to optimize it. Rather than optimizing that variable, we need the compiler to load the variable each time it is encountered. If we claim a variable risky, compiler will now not cache it in its check in.

Question 20. What Is Top Half & Bottom Half Of A Kernel?

Answer :

Sometimes to address an interrupt, a tremendous amount of work needs to be executed. But it conflicts with the velocity need for an interrupt handler. To handle this situation, Linux splits the handler into two elements – Top half of and Bottom half. The top half of is the habitual that virtually responds to the interrupt. The bottom half of alternatively is a ordinary this is scheduled with the aid of the top 1/2 to be done later at a safer time.

All interrupts are enabled at some stage in execution of the lowest half of. The top 1/2 saves the tool data into the precise buffer, schedules backside half and exits. The backside half of does the rest. This manner the top half can provider a brand new interrupt while the lowest 1/2 is operating at the previous.

Embedded Testing Interview Questions
Question 21. Difference Between Risc And Cisc Processor?

Answer :

RISC (Reduced Instruction Set Computer) should perform a few units of easy instructions concurrently. Fewer transistors are used to manufacture RISC, which makes RISC cheaper. RISC has uniform education set and those commands are also fewer in variety. Due to the less range of commands in addition to commands being simple, the RISC computers are faster. RISC emphasise on software instead of hardware. RISC can execute instructions in one machine cycle.

CISC (Complex Instruction Set Computer) is capable of executing more than one operations via a single education. CISC have rich and complicated training set and more quantity of addressing modes. CISC emphasise on hardware instead that software, making it costlier than RISC. It has a small code length, excessive cycles consistent with second and it's far slower in comparison to RISC.

Question 22. What Is Rtos?

Answer :

In an working gadget, there may be a module called the scheduler, which schedules distinct duties and determines when a procedure will execute on the processor. This manner, the multi-tasking is done. The scheduler in a Real Time Operating System (RTOS) is designed to offer a predictable execution pattern. In an embedded machine, a positive event should be entertained in strictly described time.

To meet real time requirements, the behaviour of the scheduler have to be predictable. This kind of OS which have a scheduler with predictable execution sample is known as Real Time OS(RTOS).

The functions of an RTOS are:

Context switching latency must be brief.
Interrupt latency have to be quick.
Interrupt dispatch latency must be brief.
Reliable and time certain inter procedure mechanisms.
Should guide kernel preemption.
Question 23. What Is The Difference Between Hard Real-time And Soft Real-time Os?

Answer :

A Hard real-time system strictly adheres to the cut-off date associated with the challenge. If the device fails to meet the closing date, even once, the machine is taken into consideration to have failed. In case of a soft real-time system, missing a closing date is appropriate. In this kind of machine, a critical real-time undertaking gets precedence over different duties and retains that precedence till it completes.

Embedded Processors Interview Questions
Question 24. What Type Of Scheduling Is There In Rtos?

Answer :

RTOS uses preemptive scheduling. In preemptive scheduling, the better precedence project can interrupt a running procedure and the interrupted method will be resumed later.

MATLAB Interview Questions
Question 25. What Is Priority Inversion?

Answer :

If two obligations proportion a resource, the one with higher priority will run first. However, if the lower-priority task is the use of the shared resource whilst the higher-precedence mission becomes geared up, then the higher-precedence project ought to watch for the decrease-priority task to finish. In this state of affairs, despite the fact that the undertaking has higher priority it wishes to look forward to the of entirety of the lower-priority mission with the shared resource. This is known as priority inversion.

Question 26. What Is Priority Inheritance?

Answer :

Priority inheritance is a strategy to the concern inversion hassle. The procedure expecting any useful resource which has a aid lock could have the most precedence. This is precedence inheritance. When one or extra high precedence jobs are blocked by a activity, the original precedence assignment is not noted and execution of vital section can be assigned to the job with the very best precedence in this accelerated scenario. The job returns to the unique priority level soon after executing the crucial segment.

Embedded firmware software Interview Questions
Question 27. What Is Virtual Memory?

Answer :

Virtual reminiscence is a method that lets in procedures to allocate memory in case of physical reminiscence shortage using automatic storage allocation upon a request. The benefit of the digital memory is that the program may have a bigger memory than the physical reminiscence. It lets in huge digital memory to be supplied whilst best a smaller physical memory is to be had. Virtual memory may be applied the usage of paging.

A paging gadget is pretty much like a paging gadget with swapping. When we need to execute a procedure, we swap it into reminiscence. Here we use a lazy swapper referred to as pager in preference to swapping the whole process into reminiscence. When a method is to be swapped in, the pager guesses which pages will be used based totally on a few set of rules, earlier than the system is swapped out again. Instead of swapping entire method, the pager brings most effective the vital pages into reminiscence. By that manner, it avoids reading in pointless reminiscence pages, decreasing the switch time and the quantity of physical reminiscence.

AUTOSAR Interview Questions
Question 28. What Is Kernel Paging?

Answer :

Paging is a memory management scheme with the aid of which computer systems can keep and retrieve information from the secondary reminiscence garage whilst needed in to primary reminiscence. In this scheme, the working machine retrieves records from secondary garage in equal-length blocks known as pages. The paging scheme lets in the bodily cope with space of a process to be non non-stop. Paging lets in OS to use secondary garage for information that does not suit totally into physical memory.

Question 29. Can Structures Be Passed To The Functions By Value?

Answer :

Passing structure by way of its value to a feature is viable, however not an excellent programming exercise. First of all, if we pass the structure through price and the feature adjustments a number of those values, then the cost exchange is not pondered in caller function. Also, if the structure is large, then passing the structure by means of cost way copying the entire structure to the characteristic argument stack that can gradual the program through a huge quantity.

Question 30. Why Cannot Arrays Be Passed By Values To Functions?

Answer :

In C, the array name itself represents the address of the primary detail. So, even supposing we pass the array call as argument, it'll be handed as reference and no longer its cope with.

Question 31. Advantages And Disadvantages Of Using Macro And Inline Functions?

Answer :

The gain of the macro and inline feature is that the overhead for argument passing and stuff is decreased because the function are in-covered. The gain of macro characteristic is that we are able to write kind insensitive functions. It is likewise the disadvantage of macro feature as macro features cannot do validation test. The macro and inline characteristic also increases the size of the executable.

Question 32. What Happens When Recursive Functions Are Declared Inline?

Answer :

Inlining an recursive function reduces the overhead of saving context on stack. But, inline is merely a proposal to the compiler and it does now not assure that a feature might be inlined. Obviously, the compiler might not be capable of inline a recursive feature infinitely. It won't inline it at all or it is able to inline it, only a few stages deep.

Question 33. What Is The Concatenation Operator?

Answer :

The Concatenation operator (##) in macro is used to concatenate two arguments. Literally, we will say that the arguments are concatenated, but really their fee are not concatenated. Think it this way, if we pass A and B to a macro which uses ## to concatenate those , then the end result may be AB.

Consider the example to clear the confusion-

#define SOME_MACRO(a, b) a##b

fundamental()

  int var = 15;

  printf(“%d”, SOME_MACRO(v, ar));

Output of the above software might be 15.

PLC/Microcontrollers/Microprocessors Interview Questions
Question 34. Which Parameters Decide The Size Of Data Type For A Processor ?

Answer :

Actually, compiler is the only liable for length of the facts type. But it's miles proper as long as OS allows that. If it isn't always allowable through OS, OS can pressure the scale.

Question 35. What Is Job Of Preprocessor, Compiler, Assembler And Linker ?

Answer :

The preprocessor instructions are processed and extended with the aid of the preprocessor before actual compilation. After preprocessing, the compiler takes the output of the preprocessor and the supply code, and generates assembly code. Once compiler completes its paintings, the assembler takes the assembly code and produces an meeting listing with offsets and generate object files.

The linker combines item files or libraries and produces a single executable report. It additionally resolves references to outside symbols, assigns very last addresses to features and variables, and revises code and information to mirror new addresses.

Question 36. What Is The Difference Between Static Linking And Dynamic Linking ?

Answer :

In static linking, all of the library modules used within the software are located within the very last executable file making it large in size. This is completed through the linker. If the modules used inside the program are modified after linking, then re-compilation is wanted. The gain of static linking is that the modules are present in an executable document. We don't want to worry about compatibility problems.

In case of dynamic linking, simplest the names of the module used are gift within the executable record and the real linking is done at run time whilst this system and the library modules each are gift within the reminiscence. That is why, the executables are smaller in length. Modification of the library modules used does now not pressure re-compilation. But dynamic linking may also face compatibility problems with the library modules used.

Autosys Interview Questions
Question 37. Significance Of Watchdog Timer In Embedded Systems?

Answer :

The watchdog timer is a timing device with a predefined time c program languageperiod. During that c program languageperiod, a few occasion may arise or else the device generates a time out signal. It is used to reset to the original kingdom each time some inappropriate occasions take vicinity that can bring about machine malfunction. It is typically operated by counter gadgets.

Question 38. Why ++n Executes Faster Than N+1?

Answer :

The expression ++n calls for a unmarried device guidance including INR to carry out the increment operation. In case of n+1, aside from INR, different commands are required to load the value of n. That is why ++n is quicker.

Question 39. What Is Wild Pointer?

Answer :

A pointer that isn't always initialized to any legitimate cope with or NULL is considered as wild pointer. Consider the following code fragment -

int *p;

*p = 20;

Here p isn't initialized to any legitimate cope with and nevertheless we are seeking to get admission to the deal with. The p gets any garbage location and the following assertion will corrupt that memory place.

Question forty. What Is Dangling Pointer?

Answer :

If a pointer is de-allocated and freed and the pointer isn't always assigned to NULL, then it can nevertheless contain that cope with and having access to the pointer way that we're seeking to get entry to that vicinity and it will give an blunders. This type of pointer is referred to as dangling pointer.

8051 Microcontroller Interview Questions




CFG