1.What is watchdog timer?
Ans: A watchdog timer (or computer operating properly timer) is a computer hardware timing device that triggers a system reset if the main program, due to some fault condition, such as a hang, neglects to regularly service the watchdog (writing a “service pulse” to it, also referred to as “petting the dog” or “feed the watchdog” or “waking the watchdog”). The intention is to bring the system back from the hung state into normal operation.
2.What is semaphore?
Ans : In computer science, a semaphore is a protected variable or abstract data type which constitutes the classic method for restricting access to shared resources such as shared memory in a parallel programming environment. A counting semaphore is a counter for a set of available resources, rather than a locked/unlocked flag of a single resource.
3.What is mutex?
Ans :Mutual exclusion (often abbreviated to mutex) algorithms are used in concurrent programming to avoid the simultaneous use of a common resource, such as a global variable, by pieces of computer code called critical sections.
4.Can structures be passed to the functions by value?
Ans: yes structures can be passed by value. But unnecessary memory wastage.
5.Why cannot arrays be passed by values to functions?
Ans : When a array is passed to a function, the array is internally changed to a ‘pointer’. And pointers are always passed by reference.
6.Advantages and disadvantages of using macro and inline functions?
Ans : Advantage: Macros and Inline functions are efficient than calling a normal function. The times spend in calling the function is saved in case of macros and inline functions as these are included directly into the code.
Disadvantage: Macros and inline functions increased the size of executable code.
Difference in inline functions and macro
1) Macro is expanded by preprocessor and inline function are expanded by compiler.
2) Expressions passed as arguments to inline functions are evaluated only once while _expression passed as argument to inline functions are evaluated more than once.
More over inline functions are used to overcome the overhead of function calls. Macros are used to maintain the readbility and easy maintainence of the code.
7.What happens when recursion functions are declared inline?
Ans: It is illegal to declare a recursive function as inline. Even a function is declared as inline compiler judges it to be inline or not. Many compilers can also inline expand some recursive functions; recursive macros are typically illegal.
8.Scope of static variables?
Ans:Scope of static variable is with in the file if it is static global.Scope of static variable is with in the function if variable is declared local to a function.
But the life time is throughout the program
9.What isthe difference between a ‘thread’ and a ‘process’?
In computing, a process is an instance of a computer program that is being sequentially executed by a computer system that has the ability to run several computer programs concurrently.
A single process may contain several executable programs (threads) that work together as a coherent whole. One thread might, for example, handle error signals, another might send a message about the error to the user, while a third thread is executing the actual task of the..
10. What is a Inode?
In computing, an inode is a data structure on a traditional Unix-style file system such as UFS. An inode stores basic information about a regular file, directory, or other file system object.
11. Explain the working of Virtual Memory –
Virtual memory is a computer system technique which gives an application program the impression that it has contiguous working memory (an address space), while in fact it may be physically fragmented and may even overflow on to disk storage. Systems that use this technique make programming of large applications easier and use real physical memory (e.g. RAM) more efficiently than those without virtual memory.
12.What is Concurrency? Explain with example Deadlock and Starvation.
Concurrency is nothing but execution of different transactions simultaneously on one single resource.
Dead lock :A group of threads are waiting for resources held by others in the group. None of them will ever make progress.
An example of a deadlock which may occur in database products is the following. Client applications using the database may require exclusive access to a table, and in order to gain exclusive access they ask for a lock. If one client application holds a lock on a table and attempts to obtain the lock on a second table that is already held by a second client application, this may lead to deadlock if the second application then attempts to obtain the lock that is held by the first application.
A thread may wait indefinitely because other threads keep coming in and getting the requested resources before this thread does. Note that resource is being actively used and the thread will stop waiting if other threads stop coming in.
High priority thread:
if the system is priority based system then low priority thread never gets a chance.
- Inline Functions (daniweb.com)