1. what is a non reentrant code?
Re entrant code is code which does not rely on being executed without interruption before completion. Reentrant code can be used by multiple, simultaneous tasks. Reentrant code generally does not access global data. Variables within a reentrant function are allocated on the stack, so each instance of the function has its own private data. Nonreentrant code, to be used safely by multiple processes, should have access controlled via some synchronization method such as a semaphore.
2. how is RTOS different from other OS?
A RTOS offers services that allow tasks to be performed within predictable timing constraints
3. Is unix a multitasking or multiprocessing operating system? whats the difference between the two?
unix is a multitasking operating system, multiprocessing means it can run on multiple processors, the multiproceesing os coordinates with multiple processors running in parallel.
4. what is a core dump?
A core dump is the recorded state of the working memory of a computer program at a specific time, generally when the program has terminated abnormally includes the program counter and stack pointer, memory management information, and other processor and operating system flags and information a fatal error usually triggers the core dump, often buffer overflows, where a programmer allocates too little memory for incoming or computed data, or access to null pointers, a common coding error when an unassigned memory reference variable is accessed
5. what is stack overflow and heap overflow?
stack overflow occurs when when the program tries to access memory that is outside the region reserved for the call stack
call stack contains the subroutines called, the local variables
overflow occurs when too many functions are called,huge amount of local variables are allocated
6. windows also has multiple processes has process priotities switches between multiple process, how RTOS is different from that?
RTOS has predictable timing constranints
7. how will u create a process in UNIX or our OS OSE?
We can use thr fork system call to create a process in UNIX and in OSE the system call create_process is used.
8. what is a flat memory model and a shared memory model?
in a flatmemory model the code and data segment occupies single address space.
in a shared model the large memory is divided into different segments and needs a qualifier to identify each segment
in a flat memory model the programmer doesnt need to switch for data and code
9. what is paging, segmentation y do we need it?
Paging is a techinque where in the OS makes available the data required as quickly as possible. It stores some pages from the aux device to main memory and when a prog needs a page that is not on the main memory it fetches it from aux memory and replaces it in main memory. It uses specialised algorithms to choose which page to replace from in main memory.
It deals with a concept where the data is temperorarily stored in a high speed memory for faster access. This data is duplicated in cache and the original data is stored in some aux memory. This concepts brings the average access time lower.
Segmentation is a memory management scheme. This is the technique used for memory protection. Any accesses outside premitted area would result in segmentation fault.
This technique enables noncontiguous memory to be accessed as if it were contiguous. Same as paging.
10. write a code to check whether a stack grows upwards or downwards?
if(&i > &j) printf("stack grown downwards");
else printf("stack grows upwards");
define 2 local variables one after other and try to print the address
11. why do we require semaphore?
For process synchronization, it is a mechanism to invoke the sleeping process to become ready for execution. Its mechanism where a process can wait for resources to be available.typical example is producer consumer process. The producer process creates resources and signals the semaphore saying resource is available. Consumer process waiting on the semaphore gets the signal that resource is available.
12. write a small piece of code protecting a shared memory variable with a semaphore?
13. what are the different types of semaphores and where they are used?
Binary semaphore and counting semaphore. Binary semaphore is same as mutex. Binary semaphore tries to protect only one resource.
Counting semaphore is used in case of multiple resource. For ex: we have 4 printers then the counting semaphore value will be init to 4. When it reaches 0, the task waiting on the semaphore is suspended.
14. what are the different inter process communications?
semaphore, mutex, message passing, shared memory, socket connections
15. what is present in .bss
The bss section contains uninitialized data, and is allocated at runtime. Until it is written to, it remains zeroed
16. what are the different segments of a program (code, data,stack,heap etc)
memory Segments: Code segment
This phrase used to refer to a portion of memory or of an object file that contains executable
computer instructions. It is generally readonly segment.
This is one of the sections of a program in an object file or in memory, which contains the global variables that are initialized by the programmer. It has a fixed size, since all of the data in this section is set by the programmer before the program is loaded. However, it is not readonly, since the values of the variables can be altered at runtime.
This segment of memory is part of data segment that contains uninitialized data (static variables). These are initialized to 0 and later assigned values during runtime.
This segment of memory is a special stack which stores information about the active subroutines of a task. It contains the return address to be branched to after a subroutine has finished execution. It contains local variables of the subroutines and the parameters that are passed to those sub routines.
The segment of memory which is used for dynamic memory allocation is known as heap. It is the responsibility of the programmer to deallocate it after its use. Or alternatively it will be garbage collected by the OS.
17. what is OS scheduling mechanism in our OSE?
18. how and wher the context related information is stored PCB i guess
19. what is a make command and what are al its uses?
20. what if no process responding how it is handled (watch dog timeout mechanism)
21. what is an ELF
Executable and Linking Format is a common standard file format for executables, object code, shared libraries, and core dumps.
22. what is priority inversion?
In a scenario where a low priority task holds a shared resource (example semaphore) that is required by a high priority task. This causes the execution of the high priority task to be blocked
until the low priority task has released the resource. This scenario is averted by the OS by increasing the priority of the lowproi process until it completes the task and releases the resources.
23. Locality of reference:It deals with a process accessing a resource multiple times. There are three type of localities namely
temporal A resource is referenced at point in time and will be referenced again in near future. spatial The concept that the likelihood of referencing a resource is higher if a resource near it has been referenced.
sequencial The concept of accessing the memory sequentially.
SHORT NOTES ON INTERRUPT HANDING
1) An interrupt is generated by some HW source or SW source (timer or software event).
2) CPU invokes the kernal interrupt handler.
3) Kernal interrupt handler invokes the vector handler which returns the vector number. (Vector handler has the mapping from vector number to interrupt source).
4) Kernal invokes the mask handler which masks all existing equal or low priority interrupts.
5) In interrupt routine associated with the vector number is invoked.
6) Kernal invokes the mask handler again to restore old mask.
Thread pool is a collection of managed threads usually organized in a queue, which execute the tasks in the task queue.
Creating a new thread object every time you need something to be executed asynchronously is expensive. In a thread pool you would just add the tasks you wish to be executed asynchronously to the task queue
and the thread pool takes care of assigning an available thread, if any, for the corresponding task. As soon as the task is completed, the the now available thread requests another task (assuming there is any left).
DIFFERENT TYPES OF MEMORY FRAGMENTATION
In computer storage, fragmentation is a phenomenon in which storage space is used inefficiently, reducing storage capacity and in most cases performance. The term is also used to
RTOS VS GENERAL PURPOSE OS
The biggest difference is determinacy. An RTOS will have a deterministic scheduler. For any given set of tasks your process will always execute every number of microseconds or milliseconds exactly, and the same number from schedule to schedule. operating system services consume only known and expected amounts of time
In UNIX or Windows the scheduler are usually softrealtime (as opposed to some hardreal time RTOS). Softrealtime means that the scheduler tries to assure your process runs every X number of milliseconds, but may fail to do so on some occasions.
Modern RTOSs simply make sure that a) no interrupt is ever lost, and b) no interrupt can be blocked by a lower priority process.