Top 30 Linux Embedded Systems Interview Questions You Must Prepare 19.Mar.2024

Microprocessor is managers of the resources (I/O, memory) which lie outside of its architecture Microcontroller have I/O, memory, etc. built into it and specifically designed for control.

For embedded system, the buses used for communication includes

• I2C: It is used for communication between multiple ICs
• CAN: It is used in automobiles with centrally controlled network
• USB: It is used for communication between CPU and devices like mouse, etc.

While ISA, EISA, PCI are standard buses for parallel communication used in PCs, computer network devices, etc.

Embedded systems require infinite loops for repeatedly processing or monitoring the state of the program.  For instance, the case of a program state continuously being verified for any exceptional errors that might just happen during run-time such as memory outage or divide by zero, etc.

Some of the commonly found errors in embedded systems are
• Damage of memory devices static discharges and trient current
• Address line malfunctioning due to a short in circuit
• Data lines malfunctioning
• Due to garbage or errors some memory locations being inaccessible in storage
• Inappropriate insertion of memory devices into the memory slots
• Wrong control signals

•Macros are normally used whenever a set of instructions/tasks have to be repeatedly performed. They are small programs to carryout some predefined actions.
•We normally use the #define directive in case we need to define the values of some constants so in case a change is needed only the value can be changed and is reflected throughout.
#define mul(a,b) (a*b) 
•The major disadvantage of macros is that they are not really functions and the usual error checking and stepping through of the code does not occur. 
•Inline functions are expanded whenever it is invoked rather than the control going to the place where the function is defined and avoids all the activities such as saving the return address when a jump is performed. Saves time in case of short codes.
inline float add(float a,float b)
{
 return a+b;
}
•Inline is just a request to the compiler and it is upto to the compiler whether to substitute the code at the place of invocation or perform a jump based on its performance algorithms.

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 behaviour 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 carryout their simulation results.

Examples could be the use of virtual drivers in 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 a software.

•Hardware design is designed with the collaboration of interconnected parallel components that inherits the properties of each other. Whereas, Software design is designed with sequential components, that are based on objects and threads.
•Hardware design structure doesn’t change dynamically and it can’t be created, modified or removed easily. Whereas, Software design structure can be changed dynamically and re-usability features, used to define the components. It also includes easy creation, modification and removal of the components from the software.
•Hardware design focuses on individual components that are represented using analytical model that uses the trfer functions. Whereas, Software design represent the components using computation model that can have abstract execution engine or it can use the virtual machine that are non-deterministic.

Timers in embedded system are used in multiple ways

• Real Time Clock (RTC) for the system
• Initiating an event after a preset time delay
• Initiating an even after a comparison of preset times
• Capturing the count value in timer on an event
• Between two events finding the time interval
• Time slicing for various tasks
• Time division multiplexing
• Scheduling of various tasks in RTOS

Recursion function can be used when you are aware of the number of recursive calls is not excessive. Inline functions property says whenever it will called, it will copy the complete definition of that function. Recursive function declared as inline creates the burden on the compilers execution.

With embedded system, it is possible to replace dozens or even more of hardware logic gates, input buffers, timing circuits, output drivers, etc. with a relatively cheap microprocessor.

Possible reasons could be:
•PC being overheated.
•Dust having being accumulated all around.
•CPU f not working properly .
•Faulty power connections.
•Faulty circuit board from where the power is being drawn.
•Support Drivers not having being installed. 
•Debugging steps which can be taken are:
•Cleaning the system thoroughly and maintaining it in a dust-free environment. Environment that is cool enough and facilitates for easy passage of air should be ideal enough.
•By locating the appropriate support drivers for the system in consideration and having them installed.

•Direct memory access is mainly used to overcome the disadvantages of interrupt and progam controlled I/O.
•DMA modules usually take the control over from the processor and perform the memory operations and this is mainly because to counteract the mismatch in the processing speeds of I/O units and the procesor. This is comparatively faster.
•It is an important part of any embedded systems,and the reason for their use is that they can be used for bursty data trfers instead of single byte approaches.
•It has to wait for the systems resources such as the system bus in case it is already in control of it.

•Endianness basically refers to the ordering of the bytes within words or larger bytes of data treated as a single entity.
•When we consider a several bytes of data say for instance 4 bytes of data,XYZQ the lower byte if stored in a Higher address and others in successively decreasing addresses, then it refers to the Big Endian and the vice versa of this refers to Little Endian architecture.
•Intel 80x86 usually follows Little Endian and others like IBM systems follow Big Endian formats.
•If the data is being trmitted care has to be taken so as to know as to which byte,whether the higher or the lower byte is being trmitted.
•Hence a common format prior to communication has to be agreed upon to avoid wrong interpretation/calculations.
•Usually layer modules are written so as to automate these conversion in Operating systems.

Real-time embedded systems are computer systems that monitor, respond or control an external environment. This environment is connected to the computer system through actuators, sensors, and other input-output interfaces.

•Java was mainly designed and conceptualised for code that can work on different platforms without any hassles and also for being secure enough so as to not harm or corrupt other modules of code.
•Features like exception handling, simple syntax and Automatic Garbage collection all work in its favour as the language for use in ES's.
•Also that it is widely used in the form of Java applets makes it very popular confining it to the limits of JVM. It is Dynamic in nature.
•Its use is also being exploited in enterprise systems in the form of J2EE, J2SE, J2ME in case of mobile applications.

•Deterministic operating system having guaranteed worst-case interrupt latency and context-switch times.
•Documentation providing for the minimum, average, and maximum number of clock cycles required by each system call.
•Interrupt response times should be very minute.
•Context switch time should be very low.
•Compatibility with several plugin devices.
•Overall it should be very reliable.

DMA address deals with physical addresses. It is a device which directly drives the data and address bus during data trfer. So, it is purely physical address.

Prototype of the function used to create a child process is pid_t fork(void);
•Fork is the system call that is used to create a child process. It takes no arguments and returns a value of type pid_t.
•If the function succeeds it returns the pid of the child process created to its parent and child receives a zero value indicating its successful creation.
•On failure, a -1 will be returned in the parent's context, no child process will be created, and errno will be set.
•The child process normally performs all its operations in its parents context but each process independently of one nother and also inherits some of the important attributes from it such as UID, current directory, root directory and so on.

Significance of watchdog timer in Embedded Systems.
•Watchdog timer is basically a timing device that is set for predefined time interval and some event should occur during that time interval else the device generates a time out signal.
•One application where it is most widely used is when the mobile phone hangs and no activity takes place, in those cases watchdog timer performs a restart of the system and comes to the rescue of the users.
•It is used to reset to the original state whenever some inappropriate events take place such as too many commands being given at the same time or other activities that result in malfunctioning of the GUI. It is usually operated by counter devices.

•According to the instruction sets used, computers are normally classified into RISC and CISC. RISC stands for 'Reduced Instruction Set Computing' . The design philosophy of RISC architecture is such that only one instruction is performed on each machine cycle thus taking very less time and speeding up when compared to their CISC counterparts.
•Here the use of registers is optimised as most of the memory access operations are limited to store and load operations.
•Fewer and simple addressing modes, and simple instruction formats leads to greater efficiency, optimisation of compilers, re-organisation of code for better throughput in terms of space and time complexities. All these features make it the choice of architecture in majority of the Embedded systems.
•CISC again have their own advantages and they are preferred whenever the performance and compiler simplification are the issues to be taken care of.

The microcontroller is a self-contained system with peripherals, memory and a processor that can be used as embedded system.

•Damage of memory devices due to trient current and static discharges.
•Malfunctioning of address lines due to a short in the circuit.
•Malfunctioning of Data lines.
•Some memory locations being inaccessible in storage due to garbage or errors.
•Improper insertion of Memory devices into the memory slots.
•Faulty control signals.

•It’s normally the case that some devices trfer the output either in a bursty or a sequential manner and also during input entry. If we take the example of keyboards, all the data entered is stored in a buffer and given at a time or one character at a time.
•In case of networking there may be several requests to access the same resource and all these are queued in a buffer and serviced in the order they are received. Hence to avoid the input/output units from getting overloaded with requests, we use multibyte buffers.

Interrupt latency is a time taken to return from the interrupt service routine post handling a specific interrupt.  By writing minor ISR routines, interrupt latency can be reduced.

Essential components of embedded system includes
•Hardware
•Processor
•Memory
•Timers
•I/O circuits
•System application specific circuits
•Software
•It ensures the availability of System Memory
•It checks the Processor Speed availability
•The need to limit power lost when running the system continuously
•Real Time Operating System
•It runs a process as per scheduling and do the switching from one process to another

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 electrical or mechanical system.

Semaphore or Mutex cannot be used for interrupt context in Linux Kernel. While spinlocks can be used for locking in interrupt context.

1.Interrupt latency basically refers to the time span an interrupt is generated and it being serviced by an appropriate routine defined, usually the interrupt handler.
2.External signals, some condition in the program or by the occurrence of some event, these could be the reasons for generation of an interrupt.
3.Interrupts can also be masked so as to ignore them even if an event occurs for which a routine has to be executed.
4.Following steps could be followed to reduce the latency

•ISRs being simple and short.
•Interrupts being serviced immediately
•Avoiding those instructions that increase the latency period.
•Also by prioritizing interrupts over threads.
•Avoiding use of inappropriate APIs.

A semaphore is an abstract datatype or variable that is used for controlling access, by multiple processes to a common resource in a concurrent system such as multiprogramming operating system.  Semaphores are commonly used for two purposes

• To share a common memory space
• To share access to files

Infinite Loops are those program constructs where in there is no break statement so as to get out of the loop, it just keeps looping over the statements within the block defined.

Example:

While(Boolean True) OR for(;;);
{
//Code
}

Embedded systems need infinite loops for repeatedly processing/monitoring the state of the program. One example could be the case of a program state continuously being checked for any exceptional errors that might just occur during run time such as memory outage or divide by zero etc.,

A watchdog timer is an electronic device or electronic card that execute specific operation after certain time period if something goes wrong with an electronic system.