Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Paging What is paging?

Paging is a memory management method used by operating systems. Paging allows the main memory to use data that is residing on a secondary storage device. These data are stored in the secondary storage device as blocks of same size called pages. Paging allows the operating system to use data that will not fit in to the main memory. When a program tries access a page, first the page table is checked to see whether that page is on the main memory. Page table holds details about where the pages are stored. If it is not in the main memory, it is called a page fault. Operating system is responsible for handling page faults without showing it to the program. The operating system first finds where that particular page is stored in the secondary storage and then brings it in to an empty page frame in the main memory. Then it updates the page table to indicate that the new data is in the main memory and returns the control back to the program that initially requested the page. Example

A technique used by virtual memory operating systems to help ensure that the data you need is available as quickly as possible. The operating system copies a certain number of pages from your storage device to main memory. When a program needs a page that is not in main memory, the operating system copies the required page into memory and copies another page back to the disk. One says that the operating system pages the data. Each time a page is needed that is not currently in memory, a page fault occurs. An invalid page fault occurs when the address of the page being requested is invalid. In this case, the application is usually aborted. This type of virtual memory is called paged virtual memory. Another form of virtual memory is segmented virtual memory

Problem with paging:


It is difficult to share problem/data between processes such as: 1. If the procedure p1and p2 are on same page can not set a read permission for p1 while setting write permission for p2. 2. The internal fragmentation at the last page of the process.

Segmentation What is Segmentation?


Memory segmentation is a method that provides memory protection. Each memory segment is associated with a specific length and a set of permissions. When a process tries to access the memory it is first checked to see whether it has the required permission to access the particular memory segment and whether it is within the length specified by that particular memory segment. If either of these conditions is not satisfied, a hardware exception is raised. In addition, a segment may also have a flag indicating whether the segment is in the main memory or not. If the segment is not residing in the main memory, an exception will be raised and the operating system will bring the segment from the secondary memory to the main memory. Placement policy similar to that of variable partitioning allocation .it uses one of the following methods that are: 1. Best fit 2. First fit 3. Worst fit

Drawbacks of segmentation:
1. Segment size can become enormous (lead to slow i/o transfer) 2. More difficult for memory management. 3. Need to search for the proper hole in the main memory. 4. Management of free space in main memory. 5. External fragmentation

Difference between paging and segmentation

1.Paging Computer memory is divided into small partitions that are all the same size and referred to as, page frames. Then when a process is loaded it gets divided into pages which are the same size as those previous frames. The process pages are then loaded into the frames. Segmentation Computer memory is allocated in various sizes (segments) depending on the need for address space by the process. These segments may be individually protected or shared between processes. Commonly you will see what are called Segmentation Faults in programs, this is because the data thats is about to be read or written is outside the permitted address space of that process

2. Paging: Transparent to programmer (system allocates memory) No separate protection No separate compiling No shared code Segmentation: Involves programmer (allocates memory to specific function inside code) Separate compiling Separate protection Share code

3. Segmentation is a logical unit visible to user but paging is physical unit which works internally.

You might also like