Sunday, September 25, 2011

Operating system Short Question Part3

What is a Safe State and what is its use in deadlock avoidance?
Safe State:
When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state. System is in safe state if there exists a safe sequence of all processes. Deadlock Avoidance: Ensure that a system will never enter an unsafe state. 

What is a Real-Time System?
A real time process is a process that must respond to the events within a certain time period. A real time operating system is an operating system that can run real time processes successfully.
   
What is MUTEX?

Mutex is a program object that allows multiple program threads to share the same resource, such as file access, but not simultaneously. When a program is started a mutex is created with a unique name. After this stage, any thread that needs the resource must lock the mutex from other threads while it is using the resource. The mutex is set to unlock when the data is no longer needed or the routine is finished. 
 


What is the difference between a ‘thread’ and a ‘process’?

A process is a collection of virtual memory space, code, data, and system resources. A thread is code that is to be serially executed within a process. A processor executes threads, not processes, so each application has at least one process, and a process always has at least one thread of execution, known as the primary thread. A process can have multiple threads in addition to the primary thread. Prior to the introduction of multiple threads of execution, applications were all designed to run on a single thread of execution.  

When a thread begins to execute, it continues until it is killed or until it is interrupted by a thread with higher priority (by a user action or the kernel’s thread scheduler). Each thread can run separate sections of code, or multiple threads can execute the same section of code. Threads executing the same block of code maintain separate stacks. Each thread in a process shares that process’s global variables and resources.
 
What is Semaphore?
Semaphore is the locking Mechanism used inside resource managers and resource dispensers. What is Marshalling? The process of packaging and sending interface method parameters across thread or process boundaries is marshalling.
 
Define and Explain COM?

COM stands for Component Object Model which is a specification (Standards). COM has two aspects
a: COM specifications provide a definition for what object is
b: COM provides services or blue prints for creation of object and
communication between client and server. COM is loaded when the first object of the component is created. 

What is INODE?
INODE are the data structures that contain information about the files which are created when UNIX file systems are created. Each file has an inode & is identified by an inode number (i-number) in the file system where it resides. Inode provides important information on files such as group ownership, access mode (read, write, execute permissions).

What are the different process states?

A process may be in anyone of the following states
1. NEW
2. READY
3. WAIT
4. RUNNING
5. TERMINATE
Note: TERMINATE is not a state, if the process “TERMINATE” it still exists
 
What is marshalling?
Marshalling is the process of gathering data and transforming it into a standard format before it is transmitted over a network so that the data can transcend network boundaries. In order for an object to be moved around a network, it must be converted into a data stream that corresponds with the packet structure of the network transfer protocol. This conversion is known as data marshalling. Data pieces are collected in a message buffer before they are marshaled. When the data is transmitted, the receiving computer converts the marshaled data back into an object.
 
What is Mutex Object?

A mutex object is a synchronization object whose state is set to signaled when it is not owned by any thread, and non-signaled when it is owned. For example, to prevent two threads from writing to shared memory at the same time, each thread waits for ownership of a mutex object before executing the code that accesses the memory. After writing to the shared memory, the thread releases the mutex object.
 
What is semaphore?
A semaphore object is a synchronization object that maintains a count between zero and a specified maximum value. The count is decremented each time a thread completes a wait for the semaphore object and incremented each time a thread releases the semaphore. When the count reaches zero, no more threads can successfully wait for the semaphore object state to become signaled. The state of a semaphore is set to ‘signaled’ when its count is greater than zero and ‘non-signaled’ when its count is zero. The semaphore object is useful in controlling a shared resource that can support a limited number of users. It acts as a gate that limits the number of threads sharing the resource to a specified maximum number.
 
Explain Memory Partitioning, Paging, Segmentation.
Memory partitioning is the way to distribute the Kernel and User Space Area in Memory.
Paging is actually a minimum memory, which can be swap in and swap out from Memory. In modern Server operating systems, we can use Multiple Page Size Support. That actually helps to tune OS performance, depending on type of applications.

Segmentation is actually a way to keep similar objects in one place. For example: you can have your stack stuffs in one place (Stack Segment), Binary code in another place (text segment), and data in another place (Data and BSS segment). Linux doesn’t have segment architecture. AIX has Segment architecture.
 
What is the Condition for deadlock occurrence?
Deadlock can arise if four conditions hold simultaneously.
Mutual exclusion: only one process at a time can use a resource.
Hold and wait: a process holding at least one resource is waiting to acquire additional resources held by other processes.
No preemption: a resource can be released only voluntarily by the process holding it, after that process has completed its task.
Circular wait: there exists a set {P0, P1, P2, P3} of waiting processes such that
P0 is waiting for a resource that is held by P1, P1 is waiting for a resource that
is held by P2, P2 is waiting for a resource that is held by P3, and P3 is waiting
for a resource that is held by P0.
  
What are the Methods for Handling Deadlocks? 
  • Ensure that the system will never enter a deadlock state 
  • Allow the system to enter a deadlock state and then recover. 
  • Ignore the problem and pretend that deadlocks never occur in the system; used by most operating systems.
What is a Safe State and its? use in deadlock avoidance?
When a process requests an available resource, system must decide if immediate allocation leaves the system in a safe state System is in safe state if there exist a safe sequence of all processes. Sequence <P1, P2? Pn> is safe if for each Pi, the resources that Pi can still request can be satisfied by currently available resources + resources held by all the Pj, with j<I.
If Pi resource needs are not immediately available, then Pi can wait until all Pj have finished. When Pj is finished, Pi can obtain needed resources, execute, return allocated resources, and terminate. When Pi terminates, Pi+1 can obtain its needed resources, and so on. ->Deadlock Avoidance ?ensure that a system will never enter an unsafe state.   

What is the usage of Deadlock Detection-Algorithm?  
  • When, and how often, to invoke depends on:  
  • How often a deadlock is likely to occur?
  • How many processes will need to be rolled back?  
  • If detection algorithm is invoked arbitrarily, there may be many cycles in the resource graph and so we would not be able to tell which of the many deadlocked processes, caused the deadlock.