21⟩ Tell me what are the different storage classes in C?
☛ Auto
☛ Register
☛ Static
☛ Extern or Global
“Embedded Software Engineer Frequently Asked Questions in various Embedded Software Engineer job interviews by interviewer. The set of questions are here to ensures that you offer a perfect answer posed to you. So get preparation for your new job interview”
☛ Auto
☛ Register
☛ Static
☛ Extern or Global
A static variable cannot be declared without defining it. A static variable can be defined in the header file. But doing so, the result will be having a private copy of that variable in each source file which includes the header file. So it will be wise not to declare a static variable in header file, unless you are dealing with a different scenario.
The NULL is a macro defined in C. Null pointer actually means a pointer that does not point to any valid location. We define a pointer to be null when we want to make sure that the pointer does not point to any valid location and not to use that pointer to change anything. If we don't use null pointer, then we can't verify whether this pointer points to any valid location or not.
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.
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
RTOS uses pre-emptive scheduling. In pre-emptive scheduling, the higher priority task can interrupt a running process and the interrupted process will be resumed later.
If a resource is locked, a thread that wants to access that resource may repetitively check whether the resource is available. During that time, the thread may loop and check the resource without doing any useful work. Suck a lock is termed as spin lock.
Model transformations involve multiple models that are used to define different views of a system. It provides different level of granularity that it doesn’t use either the top-down approach or the bottom-up approach to implement the basic functionality of the system. It is used to integrate the library components used that involves the iteration of the model that needs to be constructed. It also involves the analysis of the model so that the process can be made automated by using the construction tools. The compilation made the progress by improving the code that is written in high level language and the code generator produce the code that is required for the machine language.
☛ 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.
Possible reasons could be:
☛ PC being overheated.
☛ Dust having being accumulated all around.
☛ CPU fans 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.
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.,
For e.g. Customer care Telephone systems where in a pre-recorded audio file is played in case the dialer is put on hold..
- Also circuits being responsible for indicating that a particular component is active/alive during its operation by means of LED's.
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.
It’s normally the case that some devices transfer 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.
Embedded systems are used to give the response in real time. So, it consists of the real time systems that allow the correct information to be passed to get the correct responses. For example, it includes of the flight control system that produce the responses in real time and it always the take the values also in real time. If any delay been caused by the system then it deals in the fatal error. The real time system includes the system that provides the response on time with the small delay. Real time systems include of many other system such as:
Hard Real-Time Systems - These are the systems that server the purpose of having constraints that are hard and it totally depends on the time to provide the response on time.
Soft Real-Time Systems - These systems serves the purpose of having few delays in giving up the responses that can tolerate small variations.
Hybrid Real-Time Systems - These systems includes the properties from both the systems and increases the performance.
Volatile keyword is used to show that the value can be changed anytime in the program. It is used for the compiler purpose and for the customization that works with the normal variables that are stored in the memory. There are three types of optimizations associated with the “volatile” keyword:
"Read" optimizations: allow the variable to be read once and put it in the register. If it is done then there is no re-reading of the variable during each and every time the program is compiled. The value can be used from the cache that is present in the register.
"Write" optimizations: allow the variable to be written such that the last write of the variable will be considered and it will be processed on. This takes the normal values that are stored in the memory.
Instruction reordering: allow to reorder the instructions that are used by the compiler and if any modification are required after being written once. The registers are used to perform the task and keep everything together.
4 different types of inheritance relationship are Single, Multiple, Multilevel and Hybrid.
The const keyword make sure that the value of the variable declared as const can't be changed. This statement holds true in the scope of the program. The value can still be changed by outside intervention. So, the use of const with volatile keyword makes perfect sense.
Putting a break point inside ISR is not a good idea because debugging will take some time and a difference of half or more second will lead to different behavior of hardware. To debug ISR, definitive logs are better.
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
Volatile keyword is used to prevent compiler to optimize a variable which can change unexpectedly beyond compiler's comprehension. Suppose, we have a variable which may be changed from scope out of the program, say by a signal, we do not want the compiler to optimize it. Rather than optimizing that variable, we want the compiler to load the variable every time it is encountered. If we declare a variable volatile, compiler will not cache it in its register.