Embedded C Programming Interview Questions And Answers

  



Explain about forwarding Reference available in C programming language. Answer: This is the most asked Embedded System Interview Questions in an interview. Forward reference in C is actually indicating that when we plan to address or pointing one smaller data type with a specific pointer of one bigger data type in C programming language. Top Interview Questions and Answers in Embedded C. 1) What is an Embedded C? Embedded C is an extension of C programming language. C programming language is used to develop desktop based applications. While, Embedded C is used to develop micro-controller based applications such as device drivers (memory device driver, camera device driver, WIFI.

10 Microcontroller interview questions and answers. This page describes Microcontroller questionnaire written by specialists in Microcontroller embedded domain. This top 10 Microcontroller interview questions and answers will help interviewee pass the job interview for Microcontroller Handware or programming job position with ease. An embedded system is a computer system that is part of a larger system or machine. It is a system with a dedicated function within a larger e Top 18 Embedded Systems Interview Questions & Answers. C Programming Interview Questions have become a crucial part of the interview process in almost all MNC companies. This article is mainly focused on the most repeatedly asked and the latest updated questions that are appearing in most of the current interviews.

Embedded Systems Interview Questions

Many top companies are offering jobs in various roles in Embedded Testing. So, there is a huge scope for professionals in the job market. We at Mindmajix, have prepared a bunch of top interview questions in this blog that covers the basics of the embedded systems. We hope you will benefit from these questions and clear your interview easily.

Categories of Embedded Interview Questions

Q1) What is an embedded system?

Ans: An embedded system is part of a more extensive electrical or mechanical system dedicated to a specific task. It is a microcontroller or microprocessor-based.

Q2) What does the embedded system architecture consist of?

Questions

Ans: An embedded system has typically 3 components:

  • Hardware: It includes processor, memory, timers, I/O circuits, and system application-specific circuits

  • Software: It ensures the availability of system memory and processor speed.

  • Real-Time Operating System (RTOS): It supervises the application software.

Q3) What are the fundamental characteristics of an embedded system?

Ans:

  • Performs a specialized operation and repeats the same.

  • Tight constraints on design metrics.

  • Continually reacts to changes in the system’s environment.

  • Based on microprocessors or microcontrollers.

  • Software is for flexibility. Hardware is for performance and security.

Q4) What are the types of embedded systems?

Ans: Based on performance and functional requirements, there are four types:

  1. Real-time embedded systems

    1. Soft real-time embedded systems

    2. Hard real-time embedded systems

  2. Stand-alone embedded systems

  3. Networked embedded systems

  4. Mobile embedded systems

Based on performance and microcontroller, there are three types:

  1. Small-scale embedded systems

  2. Medium-scale embedded systems

  3. Sophisticated or Complex embedded systems. Free download peachtree accounting 2010.

Q5) Differences between Serial and Parallel I/O devices?

Ans: Serial:

Type

Input

Output

Synchronous

Audio/Video signal

Audio/Video signal

Asynchronous

Keypad, mouse, modem

Printer, modem

Parallel:

Type

Input

Output

Single-bit

Rotation, threshold sensors

Pulses to an external circuit

Multi-bit

Vp from ADC, sensors

LCD, printer

Q6) What are some applications of embedded systems?

Ans:

  • Identify rash driving on highways and alarm the traffic authorities through a speed-checker device.

  • Detect vehicle movement on highways and control street lights.

  • A density-based traffic signal system controls the signal timing according to the traffic density at junctions.

  • To find the exact location of a vehicle using a GPS modem.

  • For a home automation system with the Android application based remote control.

Q7) What are real-time embedded systems?

Ans: Real-time embedded systems are computer systems that monitor, respond, or control external environments.

Q8) What is a microcontroller?

Ans: Microcontrollers are self-contained systems inserted in devices to control the actions and features of a product. They are also called embedded controllers.

Q9) What is interrupt latency? How can it be reduced?

Ans: Interrupt latency is the time taken to return from a disrupted service to regular functioning.

Interrupt latency is reduced by:

  • Keeping ISRs short and straightforward

  • Immediate servicing of interrupts

  • Avoiding instructions that increase the latency period

  • Prioritizing interrupts over threads.

  • Avoiding inappropriate APIs.

Q10) Types of Buses used by embedded systems?

Ans:

Sonic riders zero gravity gamecube controller. TYPE

DESCRIPTION

Memory Bus

It is related to the processor connected to the memory.

Multiplexed Address/Data Bus

It reads and writes in the memory, but it decreases the performance because of the time consumed in the memory.

De-multiplexed Bus

It consists of two wires on the same bus. One wire has the address, and the other one has the data.

Input/Output Bus

It uses multiplexing techniques to multiplex the same input and output signals.

Q11) What are the uses of timers?

Ans: The different uses of timers in embedded systems are:

  • Real-Time Clock (RTC) for the system

  • To initiate an event after a preset time delay.

  • To capture the count value on an event.

  • To find the time interval between two events.

  • To reduce the time spent on various tasks.

  • To schedule tasks in RTOS

Q12) What is a Watchdog timer?

Ans: A watchdog timer is an electronic device that is dedicated to a specific operation after a particular time if something goes wrong with a system. New idea 4844.

Q13) Why are infinite loops used in embedded systems?

Ans: Embedded systems use infinite loops to process or monitor the state of a program repeatedly. For example, in a customer support telephone system, a pre-recorded audio file is played in case the dialer is on hold.

Q14) What are the common errors in Embedded systems?

Ans: Some of the common errors found in an embedded system are:

  • Data lines malfunctioning

  • Address line malfunctioning because of a short in the circuit

  • Some memory locations become inaccessible.

  • Wrong control signals

  • Damage of memory devices

Q15) Differences between mutexes and semaphores?

Ans:

MUTEXES

SEMAPHORES

Only the acquired thread releases it.

Another thread or process can signal it.

Mutexes always have a known owner.

The thread is not known.

It provides deadlock-free mutual exclusion.

It is a synchronization tool that overcomes that critical section problem.

Mutexes are binary semaphores. Two states are locked or unlocked.

Semaphores are counter locks.

Q16) What are recursive functions?

Ans: A recursive function is used when it is known that the number of recursive calls is not excessive. It can be declared inline if required.

Q17) What is a memory leak?

Ans: A memory leak is the accumulation of uncleared memory. It stalls the execution of the system if it reaches adequate space.

Q18) What are the advantages and disadvantages of embedded systems?

Ans: Advantages:

  • It is faster to load and is small in size.

  • It is dedicated to one specific task.

  • It is easy to manage.

  • It is cost-effective.

  • Fewer resources are needed, like memory and microprocessors.

  • It has good performance because the operating system is only for one device.

Disadvantages:

  • It is difficult to upgrade.

  • Settings need to be reset if there is any problem.

  • It is not scalable.

  • Limited hardware.

  • It is difficult to troubleshoot.

  • It is difficult to transfer data from one system to the other.

Q19) What are the reasons for a system to go blank? What are the steps to debug it?

Ans: Reasons a system could go blanks are:

  • Overheated PC

  • Accumulated dusk

  • Malfunctioning of CPU fans

  • Faulty power connections

Steps to debug are:

  • Cleaning the system and maintaining a dust-free environment.

  • Creating a cool environment for easy passage of air.

  • Locating the appropriate support drivers and installing them.

Q20) What is the automotive embedded system?

Ans: The automotive embedded system is a computer system for electronic devices that controls the mechanism of data and devices.

Embedded C Interview Questions

Q21) What is an embedded C?

Ans: Embedded C is an extension of the C programming language. It is used to develop applications based on micro-controllers such as device drivers (camera device drivers, WiFi device drivers, etc.)

Q22) What are the causes of segmentation fault error?

Ans: Segmentation fault error is a runtime error that occurs due to a few of the following reasons:

  • A pointer may not have a valid address or a memory location to point.

  • If the user tries to access a read-only memory area.

  • If the user tries to free a memory (using a pointer) which is already freed.

Q23) What is a stack overflow error in C?

Ans: Stack overflow error occurs if the program accesses the memory beyond its available limit. When this error occurs, the program terminates and does not execute further instructions.

Q24) Why is a ‘volatile’ keyboard used in C?

Ans: When a variable is used often, the compiler optimizes it and keeps the variables in its memory. Therefore, volatile prevents the compiler from any optimization.

Q25) How do you write an infinite loop code?

Ans: An infinite loop is coded by using while (1) and for(;;).

The syntax for an infinite loop using while(1)

The syntax for an infinite loop using for(;;)

Embedded systems testing interview questions

Q26) What are the levels of testing in embedded systems?

Ans: There are four levels of testing in embedded systems:

  • Unit testing

  • Integration testing

  • System testing

  • User acceptance testing

Q27) What are the phases of the Software Development Life Cycle?

Ans: There are five main stages of the software development life cycle:

  1. Requirement: In this phase, the customer fills a requirement form to write what they actually need from the product.

  2. Analysis: In this phase, the requirements are converted into documents and cover all the functional requirement specifications.

  3. Design: In this phase, the design of the product is prepared. The requirements are converted into architecture design. This phase includes:

    1. Low-Level Design Documentation (LLD)

    2. High-Level Design Documentation (HLD)

  4. Coding: In this phase, the requirements are converted into a coded form.

  5. Testing: In this phase, the software under development is tested for product quality. This includes 2 types:

    1. Static testing

    2. Dynamic testing

  6. Maintenance: In this phase, the maintenance of the product is implemented.

Q28) What is software quality assurance?

Ans: Software testing refers to the software developing process:

  • Monitoring and improving the process

  • Ensuring that standards and procedures are followed

  • Ensuring are problems are found and rectified.

Q29) What is equivalence partitioning?

Ans: Equivalence partitioning involves designing a test case to uncover a group or a class of error.

Q30) What are some of the common testing tools?

Ans: Some of the common testing tools are:

  • Quick Test Professional (QTP)

  • WinRunner

  • LoadRunner

  • TestDirector

  • Silk Test

Q31)How does a combination of functions reduce memory requirements in embedded systems?

Ans: The amount of code that has to be dealt with is reduced thus easing the overhead and redundancy is eliminated in case if there is anything common among the functions.

Memory allocation is another aspect that is optimized and it also makes sense to group a set of functions related in some way as one single unit rather than having them to be dispersed in the whole program.

Q32) How does, taking the address of local variables to result in unoptimized code?

Ans: The most powerful optimization for the compiler is register allocation. That is it operates the variable from the register, then a memory.

Generally, local variables are allocated in registers. However, if we take the address of a local variable, the compiler will not allocate the variable to register.

Q33) What is a pure function in ARM terminology?

Ans: Pure functions are those which return a result which depends only on their arguments.

They can be thought of as mathematical functions: they always return the same result if the arguments are the same. To tell the compiler that a function is pure, use the special declaration keyword __pure.

The compiler does optimization for pure functions. For example, the values which are allocated to memory can be safely cached in registers, instead of being written to memory before a call and reloaded afterward.

Microprocessor and Microcontroller Interview Questions

Q34) Is 8085 an embedded system?

Ans: It’s not an embedded system. Because it will be a part of an embedded system and it does not work on any software.

Q35) What is the role of the segment register?

Ans: In the 8086 processor architecture, memory addresses are specified in two parts called the segment and the offset. Segment values are stored in the segment registers. There are four or more segment registers: Code Segment (CS) contains a segment of the current instruction (IP is the offset), Stack segment (SS) contain a stack of the segment (SP is the offset), DS is the segment used by default for most data operations; ES is an extra segment register.

Q36)What type of registers contains an INTEL CPU?

Ans: Special function registers like accumulator, program controller (PC), data pointer (DPTR), TMOD and TCON (timing registers), 3 register banks with r0 to r7, Bit addressable registers like B.

Q37) Differentiate microprocessors and microcontrollers?

Ans: As now you are fundamentally familiar with what is a microcontroller And microprocessor, it is easy to recognize the significant contrasts between a microcontroller and microprocessor.

1. Key difference in both of them is the presence of external peripheral, where microcontrollers have RAM, ROM, EEPROM embedded in it while we have to use external circuits in the case of microprocessors.

2. As all the peripheral of microcontrollers are on the single-chip it is compact while the microprocessor is bulky.

3. Microcontrollers are made by using complementary metal-oxide-semiconductor technology so they are far cheaper than microprocessors. In addition, the applications made with microcontrollers are cheaper because they need lesser external components, while the overall cost of systems made with microprocessors is high because of the high number of external components required for such systems.

4. Processing speed of microcontrollers is about 8 MHz to 50 MHz, but on the contrary processing speed of general microprocessors is above 1 GHz so it works much faster than microcontrollers.

5. Generally microcontrollers have a power-saving system, like idle mode or power-saving mode so overall it uses less power, and also since external components are low overall consumption of power is less. While in microprocessors generally there is no power saving system and also many external components are used with it, so its power consumption is high in comparison with microcontrollers.

Q38) What is Preprocessor?

Ans: A preprocessor is a Program That processes its input data to produce output that is used as input to another program. The output is said to be a preprocessed form of the input data, which is often used by some subsequent programs like compilers. The amount and kind of processing done depend on the nature of the preprocessor.

Some Pre-processors Are Only Capable Of Performing Relatively Simple Textual Substitutions And Macro Expansions, while others have the power of full-fledged programming languages.

A Common Example From Computer programming is the processing performed on source code before the next step of compilation. In some computer languages (e.g., C and PL/I) there is a phase of translation known as preprocessing. It can also include macro processing, file inclusion, and language extensions.

Q39) Which is better a char, short, or int type for optimization?

Ans: Where possible, it is best to avoid using char and short as local variables. For the types, char and short the compiler needs to reduce the size of the local variable to 8 or 16 bits after each assignment. This is called sign-extending for signed variables and zero extending for unsigned variables.

It is implemented by shifting the register left by 24 or 16 bits, followed by a signed or unsigned shift right by the same amount, taking two instructions (zero-extension of an unsigned char takes one instruction).

Embedded C Programming Interview Questions And Answers Multiple Choice

These shifts can be avoided by using int and unsigned int for local variables. This is particularly important for calculations that first load data into local variables and then process the data inside the local variables.

Even if data is input and output as 8- or 16-bit quantities, it is worth considering processing them as 32-bit quantities

Q40) What are inline functions?

Ans: The ARM compilers support inline functions with the keyword __inline.

These results in each call to an inline function being substituted by its body, instead of a normal call.

This results in faster code, but it adversely affects code size, particularly if the inline function is large and used often.

Q41) Why do we need virtual device drivers when we have physical device drivers?

Ans: Device drivers are basically a set of modules/routines so as to handle a device for which a direct way of communication is not possible through the user's application program and these can be thought of as an interface thus keeping the system small providing for minimalistic of additions of code if any.

Physical device drivers can’t perform all the logical operations needed in a system in cases like IPC, Signals, and so on..

The main reason for having virtual device drivers is to mimic the behavior of certain hardware devices without it actually being present and these could be attributed to the high cost of the devices or the unavailability of such devices.

These basically create an illusion for the users as if they are using the actual hardware and enable them to carry out their simulation results.

Examples could be the use of virtual drivers in the case of Network simulators, also the support of virtual device drivers in case a user runs an additional OS in a virtual box kind of software.

Q42) What are the Dirac delta function and its Fourier transform and its importance?

Ans: Dirac delta function is a continuous-time function with units are and infinite amplitude at t=0.

Embedded C Programming Interview Questions And Answers Questions

The Fourier transform of the Dirac delta function is 1.

Using Dirac delta as an input to the system, we can get the system response. It is used to study the behavior of the circuit. We can use this system behavior to find the output for any input.

Q43) Differentiate testing and verification?

Ans: Verification is a front-end process and testing is a post-silicon process. Verification is to verify the functionality of the design during the design cycle. Testing is to find manufacturing faults.

Some people prefer to define a mask together with manifest constants for the set and clear values. This is also acceptable. The element that I'm looking for is the use of manifest constants, together with the |= and &= ~ constructs

Q44) #define cat(x,y) x##y concatenates x to y. But cat(cat(1,2),3) does not expand but gives preprocessor warning. Why?

Ans: In this case, the cat(x,y) is the macro which is defined by using the preprocessor directive, this will be substituted only at the place where it is called in this example it happens like this

cat(1,2)##3 which will once again become 1##2##3

here if we use ## in between we can join or concatenate only two variables that why it gives a preprocessor warning.

Q45)What Does Malloc Do?

Ans: 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 the size of(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 the execution of the functions and should be cleaned up by the programmer using the free () function.

Q46) What Are Hard and Soft Real-Time Systems?

Ans: The hard real-time Embedded Systems are the ones 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.

Details
Last Updated: Tuesday, 10 January 2017 Hits: 55806
Top 60 complex and advanced C Interview Questions and Answers for Experienced programmers covering all aspects of C programming with detailed explanations.

1) What will be the output of printf(“%d”)?

The ideal form of printf is printf('%d',x); where x is an integer variable. Executing this statement will print the value of x. But here, there is no variable is provided after %d so compiler will show garbage value. The reason is a bit tricky.
When access specifiers are used in printf function, the compiler internally uses those specifiers to access the arguments in the argument stack. In ideal scenario compiler determines the variable offset based on the format specifiers provided. If we write printf('%d', x) then compiler first accesses the first specifier which is %d and depending on the that the offset of variable x in the memory is calculated. But the printf function takes variable arguments.

Google Embedded Interview Questions

The first argument which contains strings to be printed or format specifiers is mandatory. Other than that, the arguments are optional.So, in case of only %d used without any variable in printf, the compiler may generate warning but will not cause any error. In this case, the correct offset based on %d is calculated by compiler but as the actual data variable is not present in that calculated location of memory, the printf will fetch integer size value and print whatever is there (which is garbage value to us).

2) What is the return values of printf and scanf?

The printf function upon successful return, returns the number of characters printed in output device. So, printf(“A”) will return 1. The scanf function returns the number of input items successfully matched and assigned, which can be fewer than the format specifiers provided. It can also return zero in case of early matching failure.

3) How to free a block of memory previously allocated without using free?

If the pointer holding that memory address is passed to realloc with size argument as zero (like realloc(ptr, 0)) the the memory will be released.

4) How can you print a string containing '%' in printf?

There are no escape sequence provided for '%' in C. To print '%' one should use '%%', like -

5) What is use of %n in printf()?

Ans: According to man page “the number of characters written so far is stored into the integer. indicated by the int * (or variant) pointer argument.“. Meaning if we use it in printf, it will get the number of characters already written until %n is encountered and this number will stored in the variable provided. The variable must be an integer pointer.

Above program will print 'Hello world 5 “ as Hello is 5 letter.

6) Swap two variables without using any control statement ?

We can swap variable using 2 methods. First method is as given below

Second method to swap variables is given below

7) Consider the two structures Struct A and Struct B given below. What will be size of these structures?

struct A
{
unsigned char c1 : 3;
unsigned char c2 : 4;
unsigned char c3 : 1;
}a;

struct A
{
unsigned char c1 : 3;
unsigned char : 0;
unsigned char c2 : 4;
unsigned char c3 : 1;
}a;

The size of the structures will be 1 and 2. In case of first structure, the members will be assigned a byte as follows -

76543210
c3c2c2c2c2c1c1c1

But in case of second structure -

876543210
c3c2c2c2c2c1c1c1

The :0 field (0 width bit field) forces the next bit width member assignment to start from the next nibble. By doing so, the c3 variable will be assigned a bit in the next byte, resulting the size of the structure to 2.

8) How to call a function before main()?

To call a function pragma startup directive should be used. Pragma startup can be used like this -

The output of the above program will be -

But this pragma directive is compiler dependent. Gcc does not support this. So, it will ignore the startup directive and will produce no error. But the output in that case will be -

9) What is rvalue and lvalue?

You can think lvalue as a left side operant in an assignment and rvalue is the right. Also, you can remember lavlue as location. So, the lvalue means a location where you can store any value. Say, for statement i = 20, the value 20 is to be stored in the location or address of the variable i. 20 here is rvalue. Then the 20 = I, statement is not valid. It will result in compilation error “lvalue required” as 20 does not represent any location.

10)How to pack a structure?

We can pack any structure using __attribute__((__packed__)) in gcc. Example -

We can also use, pragma pack like this -

In both cases the size of the structure will be 5. But remember, the pragma pack and the other method mentioned, both are compiler dependent.

11) How to convert a string to integer value?

We can convert a string to integer in two ways. Method 1:

Method 2:

12) Print the output of the following switch case program?

Output of this program will be 3. The position of the default is before case 1. So, even if there is no break after case 3, the execution will just exit switch case and it will not go to default case.

13) How to prevent same header file getting included multiple times?

We can use ifndef and define preprocessors. Say the header file is hdrfile.h, then we can write the header file like -

The ifndef will check whether macro HDRFILE_H_ is defined or not. If it is not defined, it will define the macro. From next time onward the statements inside ifndef will not be included.

14) Which is better #define or enum?

Embedded C Programming Interview Questions And Answers Answer

  • Enum values can be automatically generated by compiler if we let it. But all the define values are to be mentioned specifically.
  • Macro is preprocessor, so unlike enum which is a compile time entity, source code has no idea about these macros. So, the enum is better if we use a debugger to debug the code.
  • If we use enum values in a switch and the default case is missing, some compiler will give a warning.
  • Enum always makes identifiers of type int. But the macro let us choose between different integral types.
  • Macro does not specifically maintain scope restriction unlike enum. For example -

Above program will print -

15) Print the output of this pointer program?

The program will crash. The pointer p points to string “Pointers”. But the string in constant and C will not allow to change its values. Forcibly doing so, like we did it, will cause crash of the program.

  • Prev
  • 1