Sie sind auf Seite 1von 29

- NOR AMIRUL RIZAM BIN MOHAMED - MUHAMAD RIDZUAN BIN NOR ALAIHUDIN - MUHAMAD RIDHWAN BIN MOHAMAD SABERI

0831401 0918751 1014071

Task #2: Develop C/C++ code to simulate concept memory paging events to curb the problem of partitioning.

Identify the main problems (weaknesses in partitioning method). Discuss the selected solution (paging method) and verify it. Prepare a presentation that can show the idea of this task, and share it with the whole class.

How to load Process to memory (write)

Fixed size partitioning(static).


Equal size. Unequal size.

Dynamic size partitioning.

OS
Process A 4M

8M 8M 8M
Process A 4M

OS

8M 2M 4M 6M 8M 8M 8M

Process B 5M

Process B 5M Process C 6M Process D 8M

Process C 6M
Process D 8M

8M
8M

8M

8M

OS
Process A 4M

8M 8M 8M 1M (wasted) 2M (wasted)

OS
Process A 4M

8M 2M 4M 6M 8M 8M 8M

4M (wasted)

3M (wasted)
2M (wasted)

Process B 5M Process C 6M Process D 8M

Process B 5M

Process C 6M Process D 8M

8M
8M

8M

8M

OS
Process A 4M

8M

OS
Process A 4M

8M 4M

Process B 5M

24M

Process B 5M

20M

Process C 6M
Process D 8M

Process C 6M
Process D 8M

OS
Process A 4M

8M 4M

OS
Process A 4M

8M

4M
5M 6M 8M 1M(wasted)

Process B 5M

20M

Process C 6M
Process D 8M

Process B 5M Process C 6M Process D 8M

How to load process from memory (read)

OS
Process A 4M

8M

OS
Process A 4M

8M

4M
5M 6M 8M 1M(wasted)

4M
5M 6M Process C 6M

Process B 5M Process C 6M Process D 8M

Process B 5M Process D 8M

8M 1M(wasted)

OS
Process A 4M

8M

OS
Process A 4M Process E 4M

8M

4M
5M 6M

4M
5M 6M 2M(wasted) 8M 1M(wasted)

Process E 4M

Process B 5M Process D 8M

Process B 5M Process D 8M

8M 1M(wasted)

OS
Process A 4M Process E 4M

8M

OS
Process A 4M Process E 4M

8M

4M
5M 6M 2M(wasted) 8M 1M(wasted)

4M
5M 6M 2M(wasted) 8M 1M(wasted) Process B 5M

Process B 5M Process D 8M

Process D 8M

OS
Process A 4M Process E 4M

8M

OS
Process A 4M Process A 4M Process E 4M

8M

4M
5M 6M 2M(wasted) 8M 1M(wasted)

4M
5M 1M(wasted) 6M 2M(wasted) 8M 1M(wasted)

Process A 4M

Process D 8M

Process D 8M

Solution to Dynamic Partitioning

OS
Process A 4M Process A 4M Process E 4M

8M

OS
Process A 4M Process A 4M Process E 4M

8M

4M
5M 1M(wasted) 6M 2M(wasted) 8M 1M(wasted)

4M
5M 6M 8M 1M(wasted) 2M(wasted) 1M(wasted)

Process D 8M

Process D 8M

OS
Process A 4M Process A 4M Process E 4M

8M

OS
Process A 4M Process A 4M Process E 4M

8M

4M
5M 6M 8M 1M(wasted) 2M(wasted) 1M(wasted)

4M
5M 6M 8M 4M(wasted)

Process D 8M

Process D 8M

How to load Process to memory (write)

Page 0 4M

1M
1M 1M 1M

Process A

Page 1
Page 2 Page 3

1 process was divided into fixed small equal block(pages) Main Memory 10 1M 1M 1M 1M In Use

Free Frame list Process A Page table

11 12

10 11 13 15 16 17 18 19 20

In Use

13
14 15 16 17 18 19

1M
1M 1M 1M 1M 1M 1M

20

Page 0

1M
1M 1M 1M

Process A

Page 1
Page 2 Page 3

Each pages was assigned to any available memory block(frames) Main Memory 10 1M 1M 1M 1M In Use

Free Frame list Process A Page table

11 12

10 11 13 15 16 17 18 19 20

In Use

13
14 15 16 17 18 19

1M
1M 1M 1M 1M 1M 1M

20

Page 0

Process A

Page 1
Page 2 Page 3

List of each frames for the process was keep in the table list Main Memory 10
Free Frame list

Page 0 Page 1

1M 1M 1M 1M

11 12

Process A Page table

16 17 18 19 20

In Use
Page 2 In Use Page 3

10 11 13 15

13
14 15 16 17

1M
1M 1M 1M 1M 1M 1M

List of each free frames available in the memory was updated in the tables list kept by OS

18 19

20

How to load process from memory (Read)

Process A
Main Memory 10
Free Frame list Process A Page table

Page 0 Page 1

1M 1M 1M 1M

11 12

16 17 18 19 20

In Use
Page 2 In Use Page 3

10 11 13 15

13
14 15 16 17 18

1M
1M 1M 1M 1M 1M 1M

OS sent out instructions to load Process A

19

20

Process A
Main Memory 10
Free Frame list Process A Page table

Page 0 Page 1

1M 1M 1M 1M

11 12

16 17 18 19 20

In Use
Page 2 In Use Page 3

10 11 13 15

13
14 15 16 17 18

1M
1M 1M 1M 1M 1M 1M

Process A refer to table of pages in list tables

19

20

Process A
Main Memory 10
Free Frame list Process A Page table

Page 0 Page 1

1M 1M 1M 1M

11 12

16 17 18 19 20

In Use
Page 2 In Use Page 3

10 11 13 15

13
14 15 16 17 18

1M
1M 1M 1M 1M 1M 1M

Table of pages for process A pointed to every address in memory according to list.

19

20

Page 0

Process A

Page 1
Page 2 Page 3

Every data stored in each frames pointed was carried out and sort back to Process A like the initial state.

Main Memory 10
Free Frame list

Page 0 Page 1

1M 1M 1M 1M

11 12

Process A Page table

16 17 18 19 20

In Use
Page 2 In Use Page 3

13
14 15 16 17 18 19

1M
1M 1M 1M 1M 1M 1M

Table of pages for process A pointed to every address in memory according to list.

20

Page 0

Process A

Page 1
Page 2 Page 3

List of each free frames available in the memory was updated in the tables list kept by OS

Main Memory 10
Free Frame list

1M 1M 1M 1M In Use

11 12

Process A Page table

10 11 13 15 16 17 18 19 20

In Use

13
14 15 16 17 18 19

1M
1M 1M 1M 1M 1M 1M

20

Page 0

Process A

Page 1
Page 2 Page 3 10
Free Frame list

Main Memory 1M 1M 1M 1M In Use

11 12

Process A Page table

10 11 13 15 16 17 18 19

In Use

13
14 15 16 17 18 19

1M
1M 1M 1M 1M 1M 1M

Process A loaded to OS

20

20

Das könnte Ihnen auch gefallen