Skip to main content

Posts

Showing posts from August, 2019

TLB Short Note

TLB( Tranlation Look Aside Buffer   ) TLB , that is,  Tranlation Look Aside Buffer  is hardware which is used to  decrease the average access time  in non-contiguous memory allocation scheme. Every time a CPU generates a  logical address  it has to search for the frame corresponding to a  page . And now as there are many displacements within a single page, the accession to main memory for finding the  frame  for the same page will be multiple times which increases the access time. So the first time we found the frame corresponding to a page, we store this “page-frame” entry in the TLB, so that if we need it again we could simply get it just by looking in the TLB. The accession time of TLB, being a hardware is less than that of Main memory. for more info :-  visit

Deadlock Prevention Short Note

Deadlock Prevention Deadlock Characteristics:- As discussed in the  previous post , deadlock has following characteristics. Mutual Exclusion Hold and Wait No preemption Circular wait Deadlock Prevention We can prevent Deadlock by eliminating any of the above four conditions. Eliminate Mutual Exclusion:-  It is not possible to dis-satisfy the mutual exclusion because some resources, such as the tape drive and printer, are inherently non-shareable. Eliminate Hold and wait:-  Allocate all required resources to the process before the start of its execution, this way hold and wait condition is eliminated but it will lead to low device utilization. for example, if a process requires printer at a later time and we have allocated printer before the start of its execution printer will remain blocked till it has completed its execution. The process will make a new request for resources after releasing the current set of resources. This solution may lead to starvation

Inter Process Communication

Inter Process Communication(IPC)  Short Note A process can be of two type: Independent process. Co-operating process. An independent process is not affected by the execution of other processes while a co-operating process can be affected by other executing processes. Inter process communication (IPC) is a mechanism which allows processes to communicate each other and synchronize their actions. Processes can communicate with each other using these two ways: 1) Shared Memory 2) Message Passing - An operating system can implement both method of communication.  - Communication between processes using shared memory requires processes to share some variable and it completely depends on how programmer will implement it. i) Shared Memory Method Ex: Producer-Consumer problem  - There are two processes: Producer and Consumer.  - Producer produces some item and Consumer consumes that item.  - The two processes shares a common space or memo

Discuss Peterson’s solution for achieving the Mutual exclusion

Discuss Peterson’s solution for achieving the Mutual exclusion. Problem:   Given 2 process i and j, you need to write a program that can guarantee mutual exclusion between the two without any additional hardware support. Solution:   There can be multiple ways to solve this problem, but most of them require additional hardware support. The simplest and the most popular way to do this is by using Peterson Algorithm for mutual Exclusion. Basically, Peterson’s algorithm provides guaranteed mutual exclusion by using only the shared memory. It uses two ideas in the algorithm, Willingness to acquire lock. Turn to acquire lock. Explanation: The idea is that first a thread expresses its desire to acquire lock and sets  flag[self] = 1  and then gives the other thread a chance to acquire the lock. If the thread desires to acquire the lock, then, it gets the lock and then passes the chance to the 1st thread. If it does not desire to get the lock then the while loop breaks and t

Define Page Fault. Write steps to handle page faults

Define Page Fault. Write steps to handle page faults:- A page fault occurs when a program attempts to access data or code that is in its address space, but is not currently located in the system RAM. The computer hardware traps to the kernel and program counter (PC) is saved on the stack. Current instruction state information is saved in CPU registers. An assembly program is started to save the general registers and other volatile information to keep the OS from destroying it. Operating system finds that a page fault has occurred and tries to find out which virtual page is needed. Some times hardware register contains this required information. If not, the operating system must retrieve PC, fetch instruction and find out what it was doing when the fault occurred. Once virtual address caused page fault is known, system checks to see if address is valid and checks if there is no protection access problem. If the virtual address is valid, the system checks to see if a page f

What is Safe State? Define Deadlock. Explain Banker’s Algorithm to avoid deadlock.

1) What is Safe State? Define Deadlock. Explain Banker’s Algorithm to avoid deadlock. Deadlock  is a situation where a set of processes are blocked because each process is holding a resource and waiting for another resource acquired by some other process. Consider an example when two trains are coming toward each other on same track and there is only one track, none of the trains can move once they are in front of each other. Similar situation occurs in operating systems when there are two or more processes hold some resources and wait for resources held by other(s). For example, in the below diagram, Process 1 is holding Resource 1 and waiting for resource 2 which is acquired by process 2, and process 2 is waiting for resource 1. Safe State:-   If the system can allocate resources to the process in such a way that it can avoid deadlock. Then the system is in a safe state. Banker's Algorithm :-  Banker's algorithm is a  deadlock avoidance algorithm . It is na