1 / 16

Operating Systems Lecture 32 Paging Read Ch. 9.4

Operating Systems Lecture 32 Paging Read Ch. 9.4. Thinking about implementing SRTN. What do you have to change from FCFS?. Thinking about implementing SRTN. What do will you need to implement the changes?. Contiguous Allocation. Multiple-partition allocation

dora-craig
Download Presentation

Operating Systems Lecture 32 Paging Read Ch. 9.4

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. Operating SystemsLecture 32 Paging Read Ch. 9.4 Operating System Concepts

  2. Thinking about implementing SRTN • What do you have to change from FCFS? Operating System Concepts

  3. Thinking about implementing SRTN • What do will you need to implement the changes? Operating System Concepts

  4. Contiguous Allocation • Multiple-partition allocation • Initially, all non-OS memory is available for user processes. • Hole – block of available memory; • When a process arrives, it is allocated memory from a hole large enough to accommodate it. • Holes of various size are scattered throughout memory. • Operating system maintains information about:a) allocated partitions b) free partitions (hole) OS OS OS OS process 5 process 5 process 5 process 5 process 9 process 9 process 8 process 10 process 2 process 2 process 2 process 2 Operating System Concepts

  5. Dynamic Storage-Allocation Problem When a process arrives, search for a hole big enough for it. If none available, the process must wait. When a process terminates, memory is freed, creating a hole. This new hole may join with other contiguous holes to create a bigger hole. How to satisfy a request of size n from a list of free holes: • First-fit: Allocate the first hole that is big enough. • Best-fit: Allocate the smallest hole that is big enough; must search entire list, unless ordered by size. Produces the smallest leftover hole. • Worst-fit: Allocate the largest hole; must also search entire list. Produces the largest leftover hole. First-fit and best-fit better than worst-fit in terms of speed and storage utilization. Operating System Concepts

  6. External Fragmentation • As memory is allocated to processes and freed as processes terminate, the free memory space is broken into small pieces. • External Fragmentation – total memory space exists to satisfy a request, but it is not contiguous. • With the first fit memory allocation rule, given N allocated blocks, another 0.5N blocks may be lost due to fragmentation (50 percent rule). • This means 1/3 of memory is unusable! Operating System Concepts

  7. Internal Fragmentation • One method of allocating memory is to break memory into fixed sized blocks. • Memory is allocated in units of block sizes. • The memory allocated may be slightly larger than the size needed by the process. This is Internal Fragmentation. • With Internal Fragmentation, the size difference between the process size and the allocated memory is memory internal to a partition, but not being used. • Example: Block size 1024 bytes. Process size: 4048 bytes. What is the internal fragmentation size? Operating System Concepts

  8. Compaction • One can reduce external fragmentation by compaction. • Shuffle memory contents to place all free memory together in one large block. • Compaction is possible only if relocation is dynamic, and is done at execution time. • I/O problem • Latch job in memory while it is involved in I/O. • Do I/O only into OS buffers. Operating System Concepts

  9. Paging • Paging allows the physical address space of a process to be non-contiguous. • Divide physical memory into fixed-sized blocks called frames (size is power of 2, between 512 bytes and 8192 bytes). • Divide logical memory into blocks of same size called pages. • Each address generated by the CPU consists of a page number, p, and an offset, d. • Page number: Index to a page table that contains the base address of the corresponding frame in physical memory. • Page offset: Combined with the base address to define the physical memory address that is sent to the memory unit. Operating System Concepts

  10. Address Translation Architecture Operating System Concepts

  11. Paging Example Operating System Concepts

  12. Storing of Addresses Suppose the size of physical address space = 2m Suppose the page size = 2n What is the total number of pages? Allocate m bits to specify logical addresses. First m - n bits of the address specify the page number. The n lower order bits indicate the offset. Operating System Concepts

  13. Paging Example Page size = 4 bytes Physical memory = 32 bytes Number of pages = ? Where do the following map? Logical 0: Page 0, offset 0: Logical 3: Page 0, offset 3: Logical 4: Logical 13: Operating System Concepts

  14. Paging and Fragmentation • Don't have external fragmentation with paging. • Any free frame can be allocated to a process that needs it. • May have internal fragmentation with paging. • Frames are allocated as units. Last frame may not be completely full. Operating System Concepts

  15. Allocation of Frames • The O.S. keeps track of which frames are allocated and which are free in a frame table. • If a process requests n frames, there must be n frames available to satisfy the request. If so, they are allocated to the process. • As each frame is allocated to each page, the frame number is put in the page table for that process. • Note: The user views memory as contiguous space. The program is actually scattered throughout physical memory. Operating System Concepts

  16. Free Frames Before allocation After allocation Operating System Concepts

More Related