Presentation is loading. Please wait.

Presentation is loading. Please wait.

Module IV Memory Organization.

Similar presentations


Presentation on theme: "Module IV Memory Organization."— Presentation transcript:

1 Module IV Memory Organization

2 Virtual Memory In a virtual memory system, the OS manages the long pro­grams. User programs can be larger than the physical main memory (2GB). OS stores the entire program on a hard disk whose capacity is much larger than the physical memory size.

3 Virtual Memory At a given time, only some portions of the program are brought into the main memory from the hard disk. As and when needed, a portion which is not in main memory is taken from the hard disk, and at the same time, a portion of the program which is present is released out of the main memory and stored on the hard disk. This process is known as swapping. In a virtual memory system, when a program is executed, swapping is performed as per the require­ment on a continuous basis.

4 Virtual Memory

5 Virtual Memory The CPU fetches instruction and data from the main memory. Whenever the required instruction or data is not present in main memory, the hardware raises an interrupt known as virtual memory interrupt or page fault. In response, the operating system loads a section of the program (containing the required instruction or data) from the hard disk drive to the main memory. The page fault occur within an instruction cycle. After the page fault interrupt is serviced, the CPU will continue processing the partially executed instruction.

6 Virtual Memory

7 Advantages of Virtual Memory
Program size is not limited by physical memory size. User do not have to do memory allocation. Main memory allocation is done automatically according to the demands of the program. Program can be loaded in any area of physical memory It allows processes to share files easily.

8 Virtual Memory It is implemented using two techniques: Segmentation
Paging

9 Segmentation This memory management technique supports user’s view of memory.

10 User’s view of a program

11 Segmentation Users prefer to view memory as a collection of variable-sized segments : Code : to store program Data : variables defined by the code are stored Stack : Used by sub-routines and interrupt service routines to hold temporary data and addresses.

12 Segmentation All applications need to be loaded into main memory before they can be executed. In order to do so, a temporary 'segment' is created by the memory manager

13 A typical segment

14 Segmentation There can be many segments in memory at the same time.
Each one is a separate process or application and each may be a different size

15

16 Segmentation Segmentation allows the OS to do is to place each one of those segments in different parts of physical memory.

17 Segmentation

18 Segmentation In segmentation, a memory reference includes a value that identifies a segment (segment number) and an offset within that segment. A segment is associated with a flag indicating whether it is present in main memory or not information indicating where the segment is located in memory(the address of the first location in the segment)(base address) has a set of permissions Length

19 Segmentation If the segment is not present in main memory, an exception is raised and the OS will read the segment into memory from secondary storage.

20 Segmentation If a reference to a location within a segment is made,
Physical address = base address +offset A memory management unit (MMU) is responsible for translating a segment and offset (logical address) into a memory address, checking to make sure the translation can be done and that the reference to that segment and offset is permitted.

21 Segmentation The mapping is done with help of segment table.
Logical address consists of two parts: a segment number s, and offset d s is used as an index to the segment table. Each entry of segment table has base and limits. base contains starting physical address where resides in memory limit specifies length of the segments d must be between 0 and the segment limit. If not, it traps to addressing error If offset is valid, it is added to base to produce physical address

22 Segmentation: Hardware

23 Example


Download ppt "Module IV Memory Organization."

Similar presentations


Ads by Google