1 / 9

Segmentation

Segmentation. Hoyoon Jun (hoyoonjun@davinci.snu.ac.kr) School of Computer Science and Engineering Seoul National University. Motivation. Base : 32KB +. 0KB. 0KB. Operating system. Program Code. 2KB. Heap. 4KB. 16KB. (free). (not in use). 10 KB free space

emastin
Download Presentation

Segmentation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Segmentation Hoyoon Jun (hoyoonjun@davinci.snu.ac.kr) School of Computer Science and Engineering Seoul National University

  2. Motivation Base : 32KB + 0KB 0KB Operating system Program Code 2KB Heap 4KB 16KB (free) (not in use) 10 KB free space (Allocated but not in use!) 32KB 48KB (not in use) 14KB Stack Bound : 16KB 64KB • The simple approach of using a base and bounds register pair to virtualize memory is wasteful

  3. Concept of Segmentation 0KB 0KB Operating system Operating system 16KB 16KB (not in use) (not in use) Segmentation Stack (not in use) Program code Program code 32KB 32KB Heap Heap (not in use) Stack 48KB 48KB (not in use) • Define logical segment, a smaller chunk of logically related memory allocation unit • With base and bounds pair per segment, we can place segment independently in physical memory • We have three basic segments in an address space structure • Program code, heap, and stack 64KB 64KB

  4. Hardware Implementation Segment registers 26KB Stack 28KB (not in use) Offset mask Segment mask < bound 32KB Program Code 34KB Heap Heap Segment Offset Virtual address 36KB Address translator should know about the segment id and offset of the given virtual address

  5. Segment Growth Flag for Stack Stack (not in use) Segment registers Program Code Heap • Stack has one critical difference with regard to other segments • Stack grows backwards • Segment growth direction should be saved in segment register hardware

  6. Sharing Support 0KB Operating system Segment registers 16KB (not in use) Stack (not in use) Program code Heap 32KB (not in use) Stack Heap 48KB • If several processes share same program code, there is no need to store same piece of code repeatedly • With hardware support of protection bits, we can share a segment across multiple processes without harming isolation 64KB

  7. Fine-grained Segmentation 0KB Operating system Logical address space 16KB Segment table (not in use) 0 : main 1 : subroutine 32KB 2 : globals (not in use) 48KB 3 : symbols (not in use) (not in use) 4 : stack 64KB • With further hardware support, some systems provide fine-grained segmentation • Store segment table in memory • Enable a system to use segments in more flexible ways

  8. Further Issues and OS Supports 0KB 0KB Operating system Operating system 16KB 16KB allocated (not in use) allocated 32KB 32KB Compact rearrange (not in use) (not in use) 48KB 48KB allocated (not in use) allocated 64KB 64KB • Segmentation raises a number of new issues • Segment registers must be saved and restored when a process is context-switched • Unlike address space, each segment might be a different size • Physical memory become full of little hoes (external fragmentation) • Many free-list management algorithms proposed (best-fit, worst-fit, buddy…)

  9. Summaries • Segmentation helps us build a more effective virtualization of memory • Segmentation can better support sparse address spaces, by avoiding huge potential waste of memory between logical segments • Hardware implementation is also fast and straightforward • More benefits, like code-sharing, are available with appropriate hardware support • However, allocating variable-sized segments in memory leads to some problems • Free memory gets chopped up to odd-sized pieces, and makes further memory allocation more difficult • Still not flexible enough to support fully generalized, sparse address space • Large, but sparsely-used heap still consumes many memory • Need new solutions!

More Related