19
MEMORY MANAGEMENT Paging And Segmentation

Memory management

Embed Size (px)

DESCRIPTION

our project for OPERATING SYSTEM..

Citation preview

Page 1: Memory management

MEMORY MANAGEMENT

PagingAnd Segmentation

Page 2: Memory management

Involve swapping block of data from second memory

Memory needs to be allocated to ensure a reasonable supply of ready processes to consume available processor time

Memory management requirements: Relocation Protection Sharing Logical organisation Physical organisation

Memory management

Page 3: Memory management

Paging is a partition memory into small equal fixed-size chunks and divide each process into the same size chunks

Pages-The chunks of a process Frame or pages frame-The chunks of a

memory Page table:

Contains the frame location for each page in the process

Memory address consist of a page number and offset within the page

PAGING

Page 4: Memory management

Process Pages to free frames

Some of the frames in memory are use and some are free. A list of frames is maintained by the OS. Process A stored on disk and it consist of four pages. OS will find the four free frames and loads the

four pages of process A into four frames.

Page 5: Memory management

Process B consisting of three pages and Process C consisting of four pages are subsequently loaded.

Process B is suspended and swapped out to main memory. All the process in main memory will blocked OS need to bring a new process, which is process D that contain five

pages.

Page 6: Memory management

The five pages of process D are loaded into frames 5,6,11, and 12.

Page 7: Memory management

A pages tables contain one entry for each pages of the process. The table easily indexed by the pages number (starting at 0) Each pages table entry contains the number of the frame in

main memory that hold the corresponding page. A free frame list, available for pages, is maintained Thus we will se the simple paging is similar to fixed partioning.

Page 8: Memory management

manages the main memory by dividing the

memory into regions/fixed/variable size is called partitioning

Two types of partitions 1. Static Partition Whole memory is divided into fixed sized frame 2. Dynamic Partition Memory is divided into variable sized frame according to page size

Partitioning

Page 9: Memory management

Partitioning example :

P1

P2

P4

P3

P3

P1

P4

P3

P2

Static Partition

Dynamic Partition

0

10

32

25

15

0

4249

34

20

10

51

66

70 70

28

Process

Space

P1 10

P2 10

P3 14

P4 15

Total space for those of partition

Page 10: Memory management

pAGING

CPU

p d f d

Physical memory

f

p

Logical address

Physical address

Page table

Visual address of a process divided into 1. page number (p) – index to page table 2. page offset (d) – offset into page/frame

Page 11: Memory management

PAGING EXample

0 0 1 0 1 1

10

011100

000001010

111

110

101

100

011

000

010

111

110

101

100

011

001

00 01 10 11

Offset

page frame

Physical memory

Logical memory

Page size 4 bytes Memory size 32 bytes (8 pages)

Page 12: Memory management

Paging hardware Address space 2m

Page offset 2n

Page number 2m-n

p d

Page number

Page offset

m-n n

Note :Not losing any space !

Step : address translation1. Extract the page number as the n nits of the logical

address2. Use the page number as an index into process page

table to find the frame number, k3. The starting physical address of the frame is k * 2m ,

the physical address of the referenced bytes is that number plus offset.

Physical memory2m bytes

Page 13: Memory management

Segmentation

Step : Address translation from virtual to physical address 1. Extract the segment number as the n bits

of the logical address2. Use the segment number as an index into

the process segment table to find the starting physical address of the segment

3. Compare the offset, expressed in the m bits, to the length of the segment. If offset is “>=“ to the length, the address is invalid.

4. The desired physical address is the sum of the starting physical address of the segment plus offset.

Page 14: Memory management

Segmentation

CPU s d

< +

limit

base

s

Physical memory

Segment table

yes

Trap, addressing error

Physical address

no

Logical address

main

stack

Page 15: Memory management
Page 16: Memory management

Paging

logical addresspage number = 1 [000001]offset = 478 [0111011110]

Physical addressResiding frame = 6 [000110]

offset = 478 [0111011110]

Physical address = 0001100111011110

Page 17: Memory management
Page 18: Memory management

Segmentation 

logical addresspage number = 1 [0001]offset = 752 [001011110000]

 Physical address

Residing frame = 4 [0010000000100000] offset = 752 [001011110000] 

Physical address = 0010000000100000 + 001011110000

= 0010001100010000

Page 19: Memory management

The End..pROjECT: oPERATing sYSTem

From:FATIN NABILAH BT ABDUL RAMAN

CHONG LEE MANHAFIZOH BINTI MD ISA

SITI FATIHAH BT MOHD SOHAIMI

Lecturer :DR NURUL AZMA ZAKARIA