COMBINED PAGING AND SEGMENTATION

Slides:



Advertisements
Similar presentations
Memory.
Advertisements

Part IV: Memory Management
CSS430 Memory Management Textbook Ch8
Paging Hardware With TLB
4/14/2017 Discussed Earlier segmentation - the process address space is divided into logical pieces called segments. The following are the example of types.
Memory Management Design & Implementation Segmentation Chapter 4.
Chapter 8.3: Memory Management
Memory Management (II)
Memory Management 2010.
Chapter 3.2 : Virtual Memory
1 Chapter 8 Virtual Memory Virtual memory is a storage allocation scheme in which secondary memory can be addressed as though it were part of main memory.
Virtual Memory:Part 2 Kashyap Sheth Kishore Putta Bijal Shah Kshama Desai.
Chapter 91 Translation Lookaside Buffer (described later with virtual memory) Frame.
Silberschatz, Galvin and Gagne  Operating System Concepts Segmentation Memory-management scheme that supports user view of memory. A program.
A. Frank - P. Weisberg Operating Systems Simple/Basic Segmentation.
Memory Management Ch.8.
Operating Systems Chapter 8
1 Memory Management Memory Management COSC513 – Spring 2004 Student Name: Nan Qiao Student ID#: Professor: Dr. Morteza Anvari.
Chapter 7 Memory Management
8.4 paging Paging is a memory-management scheme that permits the physical address space of a process to be non-contiguous. The basic method for implementation.
1 Chapter 3.2 : Virtual Memory What is virtual memory? What is virtual memory? Virtual memory management schemes Virtual memory management schemes Paging.
Subject: Operating System.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming  To allocate scarce memory resources.
Paging Example What is the data corresponding to the logical address below:
8.1 Silberschatz, Galvin and Gagne ©2005 Operating System Principles Implementation of Page Table Page table is kept in main memory Page-table base.
CE Operating Systems Lecture 14 Memory management.
1 Memory Management (b). 2 Paging  Logical address space of a process can be noncontiguous; process is allocated physical memory whenever the latter.
By Teacher Asma Aleisa Year 1433 H.   Goals of memory management  To provide a convenient abstraction for programming.  To allocate scarce memory.
9.1 Operating System Concepts Paging Example. 9.2 Operating System Concepts.
CSC 360, Instructor Kui Wu Memory Management I: Main Memory.
Chapter 8: Main Memory. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts – 7 th Edition, Feb 22, 2005 Memory and Addressing It all starts.
8.1 Silberschatz, Galvin and Gagne ©2009 Operating System Concepts – 8 th Edition Fragmentation External Fragmentation – total memory space exists to satisfy.
Chapter 7 Memory Management Eighth Edition William Stallings Operating Systems: Internals and Design Principles.
Memory Management Chapter 5 Advanced Operating System.
Chapter 8: Memory Management. 8.2 Silberschatz, Galvin and Gagne ©2005 Operating System Concepts Chapter 8: Memory Management Background Swapping Contiguous.
W4118 Operating Systems Instructor: Junfeng Yang.
Main Memory: Paging and Segmentation CSSE 332 Operating Systems Rose-Hulman Institute of Technology.
MEMORY MANAGEMENT. memory management  In a multiprogramming system, in order to share the processor, a number of processes must be kept in memory. 
Basic Paging (1) logical address space of a process can be made noncontiguous; process is allocated physical memory whenever the latter is available. Divide.
Non Contiguous Memory Allocation
ITEC 202 Operating Systems
CSE 120 Principles of Operating
Paging COMP 755.
ITEC 202 Operating Systems
Simple/Basic Segmentation
Paging and Segmentation
Chapter 8: Main Memory.
Storage Management Chapter 9: Memory Management
Operating System Concepts
Memory Management 11/17/2018 A. Berrached:CS4315:UHD.
Segmentation Lecture November 2018.
Background Program must be brought into memory and placed within a process for it to be run. Input queue – collection of processes on the disk that are.
CSS 430: Operating Systems - Main Memory
Main Memory Background Swapping Contiguous Allocation Paging
CS399 New Beginnings Jonathan Walpole.
Virtual Memory Hardware
Main Memory Session - 16.
Lecture 3: Main Memory.
Operating System Chapter 7. Memory Management
Contents Memory types & memory hierarchy Virtual memory (VM)
Chapter 8: Memory Management strategies
2P13 Week 7.
Memory Management CSE451 Andrew Whitaker.
Lecture 35 Syed Mansoor Sarwar
CS703 - Advanced Operating Systems
COMP755 Advanced Operating Systems
Chapter 8: Main Memory CSS503 Systems Programming
CSE 542: Operating Systems
Page Main Memory.
Presentation transcript:

COMBINED PAGING AND SEGMENTATION

CONTENTS A small review of Paging Segmentation Combined Segmentation and Paging Examples

PAGING allows the physical address space of a process to be non-contiguous Extends to any levels Pages PAGING PTBR and PTLR Page Frames CPU generated Logical Address Page# Offset PageTable (One for each Process) FrameTable (One of the Main Memory)

PAGING HARDWARE

EXAMPLE-LOGICAL TO PHYSICAL ADDRESS TRANSLATION IN PAGING 16-bit logical address 6-bit page # 10-bit offset # 1 Page Table 1 1 16-bit Physical address

DISADVANTAGES ADVANTAGES No external Fragmentation Simple memory management algorithm Swapping is easy (Equal sized Pages and Page Frames) Internal fragmentation Page tables may consume more memory. Multi level paging leads to memory reference overhead.

HOW DOES USER VIEW MEMORY?? An important part of the memory management is that become unavoidable with paging is the separation of the user’s view of the memory and the actual physical memory The users view is mapped to the physical memory Thus the differentiation comes between the logical and physical memory. Do users view memory as linear array of bytes some containing instruction and other containing data??? No…Rather they would see it as collection of segments…….

SEGMENTATION It is a memory-management scheme that supports user view of memory. A program is a collection of segments which is a logical unit which may be of unequal size. Each segment may be code of a single procedure, the data of an array, or the collection of all local data values used by a particular module. Here main memory is not partitioned. When user program is compiled , compiler automatically constructs segments. The program segments are specified by programmer to the compiler (Decision made by the programmer)

SO HOW IS IT FOR C COMPILER??? Code Global Variables Heap The standard C library Stack C COMPILER

LOGICAL ADDRESSING IN SEGMENTATION Logical Address space Segment number Offset The mapping of the logical address to the physical address is done with the help of the segment table. the length of the segment SEGMENT TABLE Segment Limit Segment Base Other bits A bit is needed to determine if the segment is already in main memory (P) Another bit is needed to determine if the segment has been modified since it was loaded in main memory (M) starting address of the corresponding segment in main mem

The segments of a program can be placed anywhere in the main memory. For each process in each execution, there is one segment address table. Segment-table base register (STBR) points to the segment table’s location in memory Segment-table length register (STLR) indicates number of segments used by a program

EXAMPLE OF SEGMENTATION

EXAMPLE-LOGICAL TO PHYSICAL ADDRESS TRANSLATION IN SEGMENTATION 16-bit logical address 12-bit offset # 1 Segment Table Length Base 1 16-bit seg base 12-bit offset # 1 16-bit Physical address

SEGMENTATION HARDWARE

External fragmentation MMU STBR STLR Base Limit Other Segment table Seg 1 (code) Seg 2 (data) Seg 3 (stack) Logical Memory Segment # Offset Logical address memory access fault no Physical 0x00 as in paging: valid, modified, protection, etc. offset < limit ? External fragmentation Segment Base + Offset physical address yes

ADVANTAGES OF SEGMENTATION No internal fragmentation Segment tables consume less memory than page tables ( only one entry per actual segment as opposed to one entry per page in Paging method) Because of the small segment table, memory reference is easy. Lends itself to sharing data among processes. Lends itself to protection. As the individual lines of a page do not form one logical unit, it is not possible to set a particular access right to a page. Note that each segment could be set up an access right

PROTECTION AND SHARING Segmentation lends itself to the implementation of protection and sharing policies Each entry has a base address and length so inadvertent memory access can be controlled Sharing can be achieved by segments referencing multiple processes Two processes that need to share access to a single segment would have the same segment name and address in their segment tables. Segmentation lends itself to the implementation of protection and sharing policies. Because each segment table entry includes a length as well as a base address, a program cannot inadvertently access a main memory location beyond the limits of a segment. To achieve sharing, it is possible for a segment to be referenced in the segment tables of more than one process. The same mechanisms are, of course, available in a paging system. However, in this case the page structure of programs and data is not visible to the programmer, making the specification of protection and sharing requirements more awkward.

DISADVANTAGES External fragmentation. Costly memory management algorithm Unequal size of segments is not good in the case of swapping. So, why can’t we combine the ease of sharing and protection we get from segments with efficient memory utilization we get from pages ????

COMBINED SEGMENTATION AND PAGING In a combined paging/segmentation system a user’s address space is broken up into a number of segments. Each segment is broken up into a number of fixed-sized pages which are equal in length to a main memory frame Segmentation is visible to the programmer Paging is transparent to the programmer

COMBINING SEGMENTS AND PAGING

IMPLEMENTING SEGMENTATION Each process has: one segment table. several page tables : one page table per segment. Logical Address space Segment number : used to index the segment table who’s entry gives the starting address of the page table for that segment. Page number : used to index that page table to obtain the corresponding frame number Offset : used to locate the word within the frame.

ADDRESSES IN A SEGMENTED PAGING SYSTEM The segment number indexes into the segment table which yields the base address of the page table for that segment. Check the remainder of the address (page number and offset) against the limit of the segment. Use the page number to index the page table. The entry is the frame. (The rest of this is just like paging.) Concat the frame and the offset to get the physical address.

ADDRESS TRANSLATION CPU s so < + f Segment limit Page table base yes CPU Physical memory s so < so Logical address no p po Memory trap + Page table (for segment) f po f

ADVANTAGES Reduces memory usage as opposed to pure paging Page table size limited by segment size Segment table has only one entry per actual segment Share individual pages by copying page table entries. Share whole segments by sharing segment table entries, which is the same as sharing the page table for that segment. Most advantages of paging still hold Simplifies memory allocation Eliminates external fragmentation. In general this system combines the efficiency in paging with the protection and sharing capabilities of the segmentation.

internal fragmentation DISADVANTAGE Internal fragmentation still exists… Page 1 Page 2 Process requests a 6KB address range (4KB pages) internal fragmentation

EXAMPLE The Intel Pentium Supports both segmentation and segmentation with paging. CPU generates logical address given to segmentation unit which in turn is handed over to paging unit which generates physical address in main memory

EXAMPLE 1 Assume that a task is divided into four equal-sized segments and that the system builds an eight-entry page descriptor table for each segment. Thus, the system has a combination of segmentation and paging. Assume also that the page size is 2 Kbytes. a. What is the maximum size of each segment?       b What is the maximum logical address space for the task?       c. Assume that an element in physical location 00021ABC is accessed by this task. What is the format of the logical address that the task generates for it? What is the maximum physical address space for the system?  

SOLUTION (8 entries in the page table) x 2K = 16K. B.  (16 K) x 4 segments per task = 64K. The physical address is 32 bits wide total, so the frame number must be 21 bits wide. Thus 00021ABC is represented in binary as:               Frame                           Offset              0000 0000 0000 0010 0001 1 | 010 1011 1100     D.   The maximum physical address space is 232 = 4 GB

EXAMPLE-2 This question refers to an architecture using segmentation with paging. In this architecture, the 32-bit virtual address is divided into fields as follows: 4 bit segment number 12 bit page number 16 bit offset Find the physical address corresponding to each of the following virtual addresses (answer "bad virtual address" if the virtual address is invalid).. 00000000 20022002 10015555

Segment table Page table A Page table B Page table A CAFE F000 1 Page table B DEAD D8BF x (rest invalid) 2 BEEF X 3 BA11

SOLUTION: 1. CAFE0000. 2. Bad virtual address. 3. D8BF5555.

REFERENCES…. Silberschatz,Galvin,Gange – Operating System Concepts (7th Ed) William Stalling – Operating System (6th Ed)

THANK YOU