Posts

Page Replacement Algorithm in OS

Page Fault- When a page referenced by the CPU is not found in the main memory, it is called as a  page fault . When a page fault occurs, the required page has to be fetched from the secondary memory into the main memory. Reference String The string of memory references is called reference string. Reference strings are generated artificially or by tracing a given system and recording the address of each memory reference. The latter choice produces a large number of data, where we note two things. For a given page size, we need to consider only the page number, not the entire address. If we have a reference to a page  p , then any immediately following references to page  p  will never cause a page fault. Page p will be in memory after the first reference; the immediately following references will not fault. For example, consider the following sequence of addresses − 123,215,600,1234,76,96 If page size is 100, then the reference string is 1,2,6,12,0,0 --->

Page replacement algorithm in OS

Image
Page Replacement Algorithms The page replacement algorithm decides which memory page is to be replaced. The process of replacement is sometimes called swap out or write to disk. Page replacement is done when the requested page is not found in the main memory (page fault). There are two main aspects of virtual memory, Frame allocation and Page Replacement. It is very important to have the optimal frame allocation and page replacement algorithm. Frame allocation is all about how many frames are to be allocated to the process while the page replacement is all about determining the page number which needs to be replaced in order to make space for the requested page. Types of Page Replacement Algorithms:- Various page replacement algorithms are- FIFO Page Replacement Algorithm MRU  page Replacement Algorithm LRU Page Replacement Algorithm Optimal Page Replacement Algorithm   First In First Out (FIFO) – This is the simplest page replacement algorithm. In t

Virtual memory in OS

Image
What is Virtual Memory? Virtual Memory is a space where large programs can store themselves in form of pages while their execution and only the required pages or portions of processes are loaded into the main memory.  This technique is useful as large virtual memory is provided for user programs when a very small physical memory is there. Virtual memory Is a storage scheme that provides user an illusion of having a very big main memory. This is done by treating  a part of secondary memory as the main memory . Instead of loading one big process in main memory, operating system loads the different parts of more then one process in the main memory. By doing this, the degree of multiprogramming will be increased  and therefore CPU utilisation will be also increased. In real scenarios, most processes never need all their pages at once, for following reasons : Error handling code is not needed unless that specific error occurs, some of which are quite rare. Arrays are often

Concept of segmentation in OS

Image
                 Segmentation :- A process is divided into Segments. The chunks that a program is divided into which are not necessarily all of the same sizes are called segments. Segmentation gives user’s view of the process which paging does not give. Here the user’s view is mapped to physical memory. There are types of segmentation: virtual memory segmentation  process is divided into a number of segments, not all of which are resident at any one point in time. 2 .Simple segmentation  – Each process is divided into a number of segments, all of which are loaded into memory at  run time, though not necessarily contiguously. There is no simple relationship between logical addresses and physical addresses in segmentation. A table stores the information about all such segments and is called Segment Table. Segment Table –  It maps two-dimensional Logical address into one-dimensional Physical address. It’s each table entry has: Base Address:  It   contains the

Segmentation in OS

Image
Segmentation   In operating system,  Segmentation is  a memory management technique in which, the memory is divided into the variable size parts. Each part is known as segment which can be allocated to a process. The details about each segment are stored in a table called as segment table. Segment table is stored in one (or many) of the segments. Segment table contains mainly two information about segment: Base: It is the base address of the segment Limit: It is the length of the segment. Why Segmentation is required? Till now, we were using Paging as our main memory management technique. Paging is more close to Operating system rather than the User. It divides all the process into the form of pages regardless of the fact that a process can have some relative parts of functions which needs to be loaded in the same page. Operating system doesn't care about the User's view of the process. It may divide the same function into different pages and those pages

Terms of paging in OS

Image
Page Table- Page table is a data structure. It maps the page number referenced by the CPU to the frame number where that page is stored. Characteristics- Page table is stored in the main memory. Number of entries in a page table = Number of pages in which the process is divided. Page Table Base Register (PTBR) contains the base address of page table. Each process has its own independent page table. Working- Page Table Base Register (PTBR) provides the base address of the page table. The base address of the page table is added with the page number referenced by the CPU. It gives the entry of the page table containing the frame number where the referenced page is stored. Page Table Entry- A page table entry contains several information about the page. The information contained in the page table entry varies from operating system to operating system. The most important information in a page table entry is frame number. In general, each e

Paging in OS

Image
                      Paging  Paging is a fixed size partitioning scheme. In paging, secondary memory and main memory are divided into equal fixed size partitions. The partitions of secondary memory are called as  pages . The partitions of main memory are called as  frames . Each process is divided into parts where size of each part is same as page size. The size of the last part may be less than the page size. The pages of process are stored in the frames of main memory depending upon their availability. Different operating system defines different frame sizes. The sizes of each frame must be equal. Considering the fact that the pages are mapped to the frames in Paging, page size needs to be as same as frame size. Example- Consider a process is divided into 4 pages P 0 , P 1 , P 2  and P 3 . Depending upon the availability, these pages may be stored in the main memory frames in a non-contiguous fashion as shown- Translating Logical