Posts

Showing posts from July, 2019

Memory allocation techniques in OS

  Memory allocation techniques Memory management Memory is central to the operation of a computer system. It consists of a large array of words or bytes each with its own address.  In uniprogramming system, main memory has two parts one for the operating system and another part is for the program currently being executed.  In the multiprogramming system, the memory part of the user is further divided into accommodate processes. The task of the subdivision is cannot out by the operating system and is known as memory management. Memory management techniques The memory management techniques is divided into two parts... Uniprogramming: In the uniprogramming technique, the RAM is divided into two parts one part is for the resigning the operating system and other portion is for the user process.  Here the fence register is used which contain the last address of the operating system parts.  The operating  system will compare the user data addresses with the fence regis

Basic of memory allocation in os

                  Memory allocation Memory allocation is a process by which computer programs and services are assigned with physical or virtual memory space. Memory allocation is the process of reserving a partial or complete portion of computer memory for the execution of programs and processes. Memory allocation is achieved through a process known as memory management. Memory allocation is primarily a computer hardware operation but is managed through operating system and software applications. Memory allocation process is quite similar in physical and virtual memory management. Programs and services are assigned with a specific memory as per their requirements when they are executed. Once the program has finished its operation or is idle, the memory is released and allocated to another program or merged within the primary memory.  Memory allocation has two core types; Static Memory Allocation : The program is allocated memory at compile time. Dynamic Memory All

Introduction to memory management in OS

                      Memory management Main memory refers to a physical memory that is internal memory to the computer. Main memory is also known as ram. The computer is able to change only data in main memory. Therefore every program we execute and every file we access must to copied from a storage device into main memory. All the program are loaded into main memory this is easy to access.  Due to large storage of secondary memory like 500gb  , 1tb and so on program can't access fast and easily. All the programs are loaded in the main memeory for execution. Sometimes complete program is loaded into the memory, but some times a certain part or routine of the program is loaded into the main memory only when it is called by the program, this mechanism is called  Dynamic Loading , this enhance the performance. Also, at times one program is dependent on some other program. In such a case, rather than loading all the dependent programs, CPU links the dependent programs

Deadlock prevantion in dbms

            Deadlock prevantion For large database , deadlock prevantion method is suitable.  A deadlock can be prevented if the resources are allocated in such a way that deadlock never occur.  The DBMS analyzes the operations whether they can create deadlock situation or not, If they do, that transaction is never allowed to be executed. Deadlock prevention mechanism proposes two schemes : Wait-Die Scheme – In this scheme, If a transaction request for a resource that is locked by other transaction, then the DBMS simply checks the timestamp of both transactions and allows the older transaction to wait until the resource is available for execution. Suppose, there are two transactions T1 and T2 and Let timestamp of any transaction T be TS (T).  Now, If there is a lock on T2 by some other transaction and T1 is requesting for resources held by T2, then DBMS performs following actions: Checks if TS (T1) < TS (T2) – if T1 is the older transaction and T2 has he

Detection and recovery from deadlock in dbms

Image
                             Deadlock detaction  When a transaction waits indefinately to obtain a lock, The database managememt system should detect whether the transaction is involved in a deadlock or not. Wait for graph  Wait-for-graph  is one of the methods for detecting the deadlock situation.  This method  is suitable for smaller database. In this method a graph is drawn based on the transaction and their lock on the resource.  If the  graph created has a closed loop or a cycle, then there is a deadlock. For the above mentioned scenario the Wait-For graph is drawn below. Recovery from Deadlock  When a detection algorithm determines that a deadlock exists, the system must recover from the deadlock. The most common solution is to roll back one or more transactions to break the deadlock. Choosing which transaction to abort is known as Victim Selection. Choice of Deadlock victim In below wait-for graph transactions T26, T28 and T27 are deadlocked. In o

Deadlock handling in transaction |DBMS|

Image
                        Deadlock handling in transcation A system is in deadlock state if there exists a set of transaction such that every transaction in the set is waiting for another transaction in the set. If there exists a set of waiting transaction T0, T1_ _ _ _, Tn-1 such that T0-->T1, T1-->T2, _ _ _ _, Tn-1-->T0 so none transaction can progress in such situation. System must have proper method to deal with deadlock otherwise,            1. In real time system it may lead to life and money.            2. Will reduce resource utilisation and               Inefficiency. There are two principle for dealing with deadlock. 1 . Prevantion -- which ensure that system will never enter into deadlock state. 2 . Detection and recovery --  allow system to enter into deadlock and try to recover. Thank you viewers. This is published by soumy Sinha..        

Deadlock prevantion method | OS | DBMS

Deadlock Prevention Deadlock prevention method is suitable for a large database. If the resources are allocated in such a way that deadlock never occurs, then the deadlock can be prevented. The Database management system analyzes the operations of the transaction whether they can create a deadlock situation or not. If they do, then the DBMS never allowed that transaction to be executed. Prevantion is a method of deadlock handling which violet one of four neccesory condition of deadlock.  Voiletion of mutual exclusion :- In practicle, any resources is non sharable which means resource cannot work on more then one process at a time. For voilet mutual exclusion , all resources must be sharable that means at a time more than one process can get a hold of the resources. That approach is practically impossible. Resources is sharable or non sharable is depends on property of hardware. Mutual exclusion method can't voilet . Voiletion of hold and wait:- Three app

Deadlock handling in os

                                Deadlock handling Deadlock handling method is used to solve the problem of deadlock. There are four method used in deadlock handling. 1.  P revantion       Prevantion   means design such a system which violet at least one   of four neccesory conditions of deadlock. This ensure that the system remains free from deadlock. 2.   Avoidence   This strategy involves maintaining a set of data using which a decision is made whether to entertain the new request or not. If entertaining the new request causes the system to move in an unsafe state, then it is discarded. This strategy requires that every process declares its maximum requirement of each resource type in the beginning. The main challenge with this approach is predicting the requirement of the processes before execution. Banker’s Algorithm  is an example of a deadlock avoidance strategy.     3. Deadlock detection and recovery This strategy involves waiting until a deadloc

Deadlock in dbms

Image
next → ← prev Deadlock in DBMS A deadlock is a condition where two or more transactions are waiting indefinitely for one another to give up locks. Deadlock is said to be one of the most feared complications in DBMS as no task ever gets finished and is in waiting state forever. For example:  In the student table, transaction T1 holds a lock on some rows and needs to update some rows in the grade table. Simultaneously, transaction T2 holds locks on some rows in the grade table and needs to update the rows in the Student table held by Transaction T1. Now, the main problem arises. Now Transaction T1 is waiting for T2 to release its lock and similarly, transaction T2 is waiting for T1 to release its lock. All activities come to a halt state and remain at a standstill. It will remain in a standstill until the DBMS detects the deadlock and aborts one of the transactions. Deadlock Avoidance When a database is stuck in a deadlock state, then it is better to avoid the database rath

Two phase locking protocol in dbms

Image
Two Phase Locking (2PL) Protocol Two-Phase locking protocol which is also known as a 2PL protocol. It is also called P2L. In this type of locking protocol, the transaction should acquire a lock after it releases one of its locks. This locking protocol divides the execution phase of a transaction into three different parts. In the first phase, when the transaction begins to execute, it requires permission for the locks it needs. The second part is where the transaction obtains all the locks. When a transaction releases its first lock, the third phase starts. In this third phase, the transaction cannot demand any new locks. Instead, it only releases the acquired locks. The Two-Phase Locking protocol allows each transaction to make a lock or unlock request in two steps: Growing Phase : In this phase transaction may obtain locks but may not release any locks. Shrinking Phase : In this phase, a transaction may release locks but not obtain any new lock example:-      

LOCK BASED PROTOCOL IN DBMS

Image
                                             LOCK BASED PROTOCOL To achieve consistency isolation is the most importent idea , locking is simplest idea to achive isolation . it first obtain a lock on a data item then preferred a desired operation and then unlock it. Database systems equipped with lock-based protocols use a mechanism by which any transaction cannot read or write data until it acquires an appropriate lock on it. to provide bettar concurrency along with isolation we use different modes of locks. shared mode. exclusive mode. shared mode :- in this transaction can perform read operation , any other transaction can also obtain some lock on same data at same time so it is called shared. it is denoted by lock-s(a).                                               exclusive mode :-  Data item can be both read as well as written.This is Exclusive and cannot be held simultaneously on the same data item. it is denoted by lock-x(A).  any other transact

concurrency control protocol in dbms

                                      concurrency control The   concurrency control   is the coordination of the simultaneous execution of a transaction in a multiuser database system.  The concurrency control can ensure the serializability of the transaction in a multiuser database environment and that is the main objective of concurrency control.  There is only One way in which the required data items can be accessed in a mutually exclusive manner. That is while one transaction is accessing a data item another transaction can modify that data item. The most common method used to implement this requirement is to allow a transaction to access a data item only if it is currently holding a lock on that item.                                        concurrency control technique concurrency control technique is used to create consistent schedule. it guarantes to generate schedule which satisfy these properties specially. we use some protocol to design and create consist

SERIALIZIBILITY IN DBMS

                      SERIALIZIBILITY   When multiple transactions are running concurrently then there is a possibility that the database may be left in an inconsistent state. Serializability is a concept that helps us to check which  schedules  are serializable. A serializable schedule is the one that always leaves the database in consistent state. What is a serializable schedule? A serializable schedule always leaves the database in consistent state. A  serial schedule  is always a serializable schedule because in serial schedule, a transaction only starts when the other transaction finished execution. However a non-serial schedule needs to be checked for Serializability. A non-serial schedule of n number of transactions is said to be serializable schedule, if it is equivalent to the serial schedule of those n transactions. A serial schedule doesn’t allow concurrency, only one transaction executes at a time and the other starts when the already running transaction finish

Concept of concurrency in dbms

                          CONCURRENCY Concurrency is the ability of a database to allow multiple users to affect multiple transactions.  This is one of the main properties that separates a database from other forms of data storage like spreadsheets. Data concurrency means that many users can access data at same time. Advantages of concurrency The good is to serve many users and provides better throughput by sharing resources. Reduced waiting time response time or turn around time. Increased throughput or resource utilization If we run only one transaction at a time than the acid property is sufficient but it is possible that when multiple transactions are executed concurrently than database may become inconsistent. Overlapping with the input-output activity with CPU also makes the response time better. But interleaving of instruction between transaction may also lead to many problems due to which concurrency control is required. Problems due to concurrency Th

Traversing in the binary tree in data structure

Image
Tree traversal is the process of visiting each node in the tree exactly once. Three traversal techniques:- 1.preorder traversal 2.inorder traversal 3.postorder traversal                                 Preorder traversal To traverse a binary tree in preorder , following operations are carried out:- 1.visit the root. 2.traverse the left subtree of root. 3.traverse the right subtree of root. Algorithm :- Algorithm preorder(t) { If t!=0 then { Visit(t); Preorder(t->child) Preorder (t->rchild) } } Preorder traversal- 7,1,0,3,2,5,4,6,9,8,10                       Inorder traversal To traverse a binary tree in inorder traversal , following operation are carried out:- 1.traverse the left most subtree. 2.visit the root. 3.trverse the right most subtree. Algorithm           Algorithm inorder (t) { If t!=0 then { Inorder (t->lchild); Visit(t); Inorder(t->rchild); } } Example:-       Inorder traversal- 0,1,2,3,4,5,6,7,8,9,10      

Representation of binary tree in memory

Image
Representing Binary Tree in memory Let  T  be a Binary Tree. There are two ways of representing  T  in the memory as follow Sequential Representation of Binary Tree. Link Representation of Binary Tree. 1) Linked Representation of Binary Tree Consider a Binary Tree  T .  T  will be maintained in memory by means of a linked list representation which uses three parallel arrays;  INFO ,  LEFT , and  RIGHT pointer variable  ROOT  as follows. In Binary Tree each node  N  of  T  will correspond to a location  k  such that LEFT [k]  contains the location of the left child of node  N . INFO [k]  contains the data at the node  N . RIGHT [k]  contains the location of right child of node  N . Representation of a node: In this representation of binary tree root will contain the location of the root  R  of  T . If any one of the subtree is empty, then the corresponding pointer will contain the null value if the tree  T  itself is empty, the  ROOT  will contain the null value.

Types of binary tree

Image
There are two types of binary tree : 1.full binary tree 2.complete binary tree FULL BINARY TREE A full binary tree which is also called as proper binary tree or 2-tree is a tree in which all the node other than the leaves has exact two children. COMPLETE BINARY TREE A complete  binary tree is defined as if all levels are completely filled except possibly the last level has all keys as left as possible. --> last level has no child is called complete binary tree. Thank you viewers . This is published by soumy Sinha.. If you have doubt then pls ask in comment box .. If u like then pls share ,and subscribe ..

Types of properties of binary tree in data structure

Image
Types of Properties of Binary Trees Rooted binary tree:  It has a root node and every node has atmost two children. Full binary tree:  It is a tree in which every node in the tree has either 0 or 2 children. The number of nodes,  n , in a full binary tree is atleast n = 2h – 1, and atmost  n = 2 h+1  – 1 , where  h  is the height of the tree. The number of leaf nodes  l , in a full binary tree is number,  L  of internal nodes + 1, i.e,  l = L+1 . Perfect binary tree:  It is a binary tree in which all interior nodes have two children and all leaves have the same depth or same level. A perfect binary tree with  l  leaves has  n = 2l-1 nodes. In perfect full binary tree,  l = 2h  and  n = 2h+1 - 1  where,  n  is number of nod justes,  h  is height of tree and  l  is number of leaf nodes Complete binary tree:  It is a binary tree in which every level, except possibly the last, is completely filled, and all nodes are as far left as possible. The number of internal no