Presentation is loading. Please wait.

Presentation is loading. Please wait.

Chapter 4 Storage Management (Memory Management).

Similar presentations

Presentation on theme: "Chapter 4 Storage Management (Memory Management)."— Presentation transcript:

1 Chapter 4 Storage Management (Memory Management)

2 2 Chapter Objectives This chapter will provide you: How data are map from storage device to Memory? What is Logical Address and Physical Address? What is a role of MMU? Process of Memory management?

3 3 Introduction The main purpose of a computer system is to execute programs. These programs, together with the data they access, must be in main memory (at least partially) during execution. To improve both the utilization of the CPU and the speed of its response to users, the computer must keep several processes in memory.

4 4 Since main memory is usually too small to accommodate all the data and programs permanently, the computer system must provide secondary storage to back up main memory. The file system provides the mechanism for on-line storage of and access to both data and programs residing on the disks. A file is a collection of related information defined by its creator. The files are mapped by the operating system onto physical devices. Files are normally organized into directories to ease their use.

5 5 Binding of Instructions and Data to Memory Usually, a program resides on a disk as a binary executable file. The program must be brought into memory and placed within a process for it to be executed. Depending on the memory management in use, the process may be moved between disk and memory during its execution. The collection of processes on the disk that is waiting to be brought into memory for execution forms the input queue.

6 6 Compile time: If memory location known a priori, absolute code can be generated; must recompile code if starting location changes. Load time: Must generate relocatable code if memory location is not known at compile time. Execution time: Binding delayed until run time if the process can be moved during its execution from one memory segment to another. Need hardware support for address maps (e.g., base and limit registers). Address binding of instructions and data to memory addresses can happen at three different stages.

7 7 Multistep Processing of a User Program

8 8 Logical vs. Physical Address Space The concept of a logical address space that is bound to a separate physical address space is central to proper memory management. Logical address – generated by the CPU; also referred to as virtual address. Physical address – address seen by the memory unit. The compile-time and load-time address-binding methods generate identical logical and physical addresses. However, the execution-time addresses binding scheme results in differing logical and physical addresses.

9 9 Memory-Management Unit ( MMU ) The run-time mapping from virtual to physical addresses is done by a hardware device called the (MMU) Hardware device that maps virtual to physical address. In MMU scheme, the value in the relocation register is added to every address generated by a user process at the time it is sent to memory. The user program deals with logical addresses; it never sees the real physical addresses.

10 10 Dynamic relocation using a relocation register

11 11 Dynamic Loading Routine is not loaded until it is called Better memory-space utilization; unused routine is never loaded. No special support from the operating system is required implemented through program design.

12 12 Swapping A process can be swapped temporarily out of memory to a backing store, and then brought back into memory for continued execution. Backing store – fast disk large enough to accommodate copies of all memory images for all users; must provide direct access to these memory images. Roll out, roll in – swapping variant used for priority-based scheduling algorithms; lower-priority process is swapped out so higher-priority process can be loaded and executed. Modified versions of swapping are found on many systems, i.e., UNIX, Linux, and Windows.

13 13 Schematic View of Swapping

14 14 Memory Protection Before discussing memory allocation, we must discuss the issue of memory protection protecting the operating system from user processes, and protecting user processes from one another. Valid-invalid bit attached to each entry in the page table: “valid” indicates that the associated page is in the process’ logical address space, and is thus a legal page. “invalid” indicates that the page is not in the process’ logical address space.

15 15 Memory protection process

16 16 Memory Allocation One of the simplest methods for memory allocation is to divide memory into several fixed-sized partitions. Each partition may contain exactly one process. Main memory usually into two partitions: Resident operating system, usually held in low memory with interrupt vector. User processes then held in high memory.

17 17 Segmentation Segmentation is a memory-management scheme that supports this user view of memory. A logical-address space is a collection of segments. Each segment has a name and a length. The user's view of memory is not the same as the actual physical memory. The user's view is mapped onto physical memory. For simplicity of implementation, segments are numbered and are referred to by a segment number, rather than by a segment name.

18 18 User’s View of a Program

19 19 Logical View of Segmentation 1 3 2 4 1 4 2 3 user spacephysical memory space

20 20 Example of Segmentation

21 21 Virtual memory separation of user logical memory from physical memory. Only part of the program needs to be in memory for execution. Logical address space can therefore be much larger than physical address space. Allows for more efficient process creation.

22 22 Transfer of a Paged Memory to Contiguous Disk Space

Download ppt "Chapter 4 Storage Management (Memory Management)."

Similar presentations

Ads by Google