• No results found

Tut-6 With Solution

N/A
N/A
Protected

Academic year: 2021

Share "Tut-6 With Solution"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

KSU/CCIS

KSU/CCIS

CSC227

CSC227

Tutorial # 6 – Memory Management

Tutorial # 6 – Memory Management

SUMMER - 2010

SUMMER - 2010

Question # 1: Question # 1:

Assume that the main memory has the following 5 fixed partitions with the following sizes: 100KB, Assume that the main memory has the following 5 fixed partitions with the following sizes: 100KB, 500KB, 200KB, 300KB and 600KB (in order)

500KB, 200KB, 300KB and 600KB (in order) a)

a) Expalin the following Expalin the following allocation algorithms: First-fit, Best-fit and Worst-fit.allocation algorithms: First-fit, Best-fit and Worst-fit. b)

b) How would each of the First-fit, Best-fit and Worst-fit algorithms place processes of 212KB,How would each of the First-fit, Best-fit and Worst-fit algorithms place processes of 212KB, 417KB, 112KB and 426KB (in order)?

417KB, 112KB and 426KB (in order)? c)

c) Compute the total memory size that is not used Compute the total memory size that is not used for each algorithm.for each algorithm. d)

d) Which algorithm makes the efficient use Which algorithm makes the efficient use of the memory?of the memory?  Answer

 Answer Q 1:Q 1:

a)

a)

Form your book.

Form your book.

b)

b)

Fisrt-fit

Fisrt-fit

Best-fit

Best-fit

Worst-fit

Worst-fit

100K

100K

100K

100K

100K

100K

500K

500K

212K

212K

500K

500K

417K

417K

500K

500K

417K

417K

288K

288K

83K

83K

83K

83K

200k

200k

112k

112k

200K

200K

112K

112K

200K

200K

88K

88K

88K

88K

300K

300K

300K

300K

212K

212K

300K

300K

112K

112K

88K

188K

88K

188K

600K

600K

417K

417K

600K

600K

426K

426K

600K

600K

212K

212K

183K

183K

174K

174K

388K

388K

c)

c)

First-fit = 1700 – 741 = 959

First-fit = 1700 – 741 = 959

Best-fit = 1700

Best-fit = 1700

– 1167

– 1167

=

=

533

533

Worst-fit = 1700 – 741 = 959

Worst-fit = 1700 – 741 = 959

d)

d)

Memeory Utilization Ratio:

Memeory Utilization Ratio:

First-fit = 741 / 1700 = 43.5%

First-fit = 741 / 1700 = 43.5%

Best-fit = 1167 / 1700 = 68.6%

Best-fit = 1167 / 1700 = 68.6%

Worst-fit = 741 / 1700 = 43.5 %

Worst-fit = 741 / 1700 = 43.5 %

Best-fit has the most efficient use

(2)

Question # 2:

Assume that the MMU is using the multiple variable partition schemes. The memory size is 2560KB, from which the OS uses 400KB. You have the following processes:

Process Size CPU burst

P1

600K

10

P2

1000K

5

P3

300K

20

P4

700K

8

P5

500K

15

Using the First-fit allocation technique and the multiprogramming system (FCFS), do the following (without using compaction)

a) Load and execute the processes until P5 is loaded (do not terminate P5). b) Every time a program is loaded, compute the external fragmentation.

c) Assuming P5 is now terminated and P6 requires 1000K, (the P3 and P4 are still in the memory) how would you compact best the memory so to enable P6 to be loaded?

 Answer Q 2:

a) Solution

b) Soultion

Time = 0

Time = 10

Time = 16

OS

400K

OS

400K

OS

400K

P1

600K

#Free#

600K

P4

700K

P2

1000K

P2

1000K

P5

500K

P3

300K

P3

300K

#Free#

400K

P3

300K

#Free#

260K

#Free#

260K

#Free#

260K

EF = 0

EF = 860K

EF = 660K

(3)

c) Soutlion

P5 trem

OS

400K

P4

700K

#Free#

900K

P3

300K

#Free#

260K

Can get most free space in less moves if you move P3 up.

Question # 3:

Assume that we have the following jobs to be scheduled using FCFS algorithm with variable partition memory scheme:

 Job Size CPU  J1 50 KB 13  J2 120 KB 3  J3 70 KB 9  J4 20 KB 3  J5 105 KB 8 6 55 KB 13

Memory size is 256KB; Jobs are initially loaded in memory as follows:

J1 50 KB

J2 120 KB

J3 70 KB

16 KB

Show how the memory will look after scheduling job 6 (assume no memory compaction is allowed) using both FCFS and Best-fit allocation technique.

P5 trem

OS

400K

P4

700K

P3

300K

#Free#

1160K

(4)

 Answer Q 3:

J1

50K

J2

120K

J3

70K

#Free# 16K

Time = 0

Time = 13

Time = 16

Time = 25

Question # 4:

Assume that we have the following jobs to be executed on a time-sharing operating system (Quantum = 4 ms) with a total user memory of 256 KB.

 Job No. Arrival time (ms)  Memory size (KB) CPU Time (ms) 1 0 120 8 2 2 70 4 3 2 50 12 4 2 100 12 5 0 40 4 6 2 120 4 7 0 60 8 8 0 30 8

Show how the memory will look after loading Job No 6 using the Best-fit allocation technique with no compaction.  Answer Q 4:

J4

20K

#Free# 30K

J2

120K

J3

70K

#Free# 16K

J4

20K

J5

105K

#Free# 45K

J3

70K

#Free# 16K

J4

20K

J5

105K

J6

55K

#Free# 76K

(5)

Question # 5:

Consider a logical address space of 8 pages; each page is 2048 byte long, mapped onto a physical memory of 64 frames.

a) What are the sizes of the logical and physical spaces?

b) How many bits are there in the logical address and how many bits are there in the physical address?

c) A 6284 bytes program is to be loaded in some of the available frames= {10, 8, 40, 25, 3, 15, 56, 18, 12, 35}. Show the contents of the program’s PMT.

d) What is the size of the internal fragment?

e) Convert the following logical addresses 2249, 5245 and 10512 to physical addresses.

 Answer Q 5:

a) Physical space size = 64 * 2048 = 2

17

 bytes.

Logical space size = 8 * 2048 = 2

14

 bytes

b) Logical @ field is 14 bits long.

Physical @ field is 17 bits long.

c) Page size = 2048 bytes, so program is divided into 6284/2048 = 4 pages

PMT

Index

Frame #

Valid/Invalid

0

10

V

1

8

V

2

40

V

3

25

V

4

I

5

I

6

I

7

I

FL { 3, 15, 56, 18, 12, 35}

d) There is interanl fragment in page number 3,

4 pages * 2048 = 8192 bytes

Program size is 6284

Internal fragment = 8192 – 6284 = 1908 bytes. (all in page number 3)

e) 2249

 <1, 201>

 <8, 201>

 16585

5245

 <2, 1149>

 <40, 1149>

 83069

10512

 <5, 272>

 Trap (page is invalid)

(6)

Question # 6:

Consider a paged memory of 64 pages of 256 bytes each.

a) What is the size of the logical space and the number of bits of a logical address?

b) Assume that the free frame list is {29, 4, 18, 5, 22, 15, 7, 2} and two programs P1 (4 pages), P2 (2 pages) are waiting to be loaded. Perform the memory allocation of P1 and P2 and show their PMTs.

c) Assume that PMT is kept in memory and two register associative memory. The access time to the memory is 480ns and the access to associative memory is 50ns. What is the effective access time to the memory if the hit ration in the associative memory is 50%? 90%?

d) Under what condition is an associative memory effective?

 Answer Q 6:

a) Logical space size = 64 * 256 = 2

6

 * 2

8

 = 2

14

  bytes

Logical @ field is 14 bits long.

b)

PMT of P1

PMT of P2

Index Frame# V/I

Index Frame# V/I

0

29

V

1

4

V

2

18

V

3

5

V

FL { 7, 2 }

c) Memory access time = 480 ns.

Associative memory access time = 50 ns.

Effective access time =

(access time for associative memory + access time for memory) * hit probability

+ (access time for associative memory + 2 * access time for memory) * miss

probability

-

If hit ration 50%:

EAT = (50 + 480) * 0.50 + ( 50 + 2 * 480) * 0.50 = 265 + 505 = 770

-

If hit ration 90%:

EAT = (50 + 480) * 0.90 + ( 50 + 2 * 480) * 0.10 = 477 + 101 = 578

d) A higher hit probability make associative memory effective.

0

22

V

(7)

Question # 7:

a) Assume a page size of 1KB, the logical address space is 8KB and the physical address space is 16KB. Answer the following questions:

i. What is the highest degree of parallelism?

ii. What is the length in bits of the physical address field? iii. What is the length in bits of the logical address field? iv. What is the length of the Page Table?

b) Assume that the page size is 128 bytes; the current program size is 635 bytes and the physical space 2048 bytes. Before the program is loaded the free frame list is {10, 7, 2, 9, 12, 4, 8, 14}. Answer the following questions after loading t he above program in main memory:

i. What is the internal fragment size? ii. What is the physical address of 128? iii. What is the physical address of 635?

iv. What is the logical address of the 2-D physical address <10,120>?

 Answer Q 7: a) v. 16 programs. vi. 16KB = 24*210 = 214 14 bits vii. 8KB = 23*210 = 213 13 bits viii. 23 = 8 pages. b) v. 5 vi. 7 * 128 + (128 – 128) = 896 vii. 12 * 128 + (635 – 512) = 1659 viii. 120

(8)

Question # 8:

Consider the following segment mapping table (SMT)

Segment Base Length (limit)

0 219 600

1 2300 14

2 90 100

3 1327 580

4 1952 96

What are the physical addresses of the following logical addresses? a) <0, 430> b) <1, 10> c) <2, 500> d) <3, 500> e) <4, 122> f) <6, 1952>  Answer Q 8:

a) <0, 430>

 219 + 430 = 649

b) <1,10>

 2300 + 10 = 2310

c) <2,500>

 Trap (500 >= 100)

d) <3,500>

 1327 + 500 = 1827

e) <4,122>

 Trap (122 >= 96)

f) <6,1952>

 Trap (6 is an invalid entry)

Question # 9:

Given a logical address field with the following format:

2 bits 16 bits 8 bits

Seg # Page # Page Offset

Answer the following questions:

a. What is the number of segments?

b. What is the maximum size of the segment? c. What is the size of a page?

d. What is the maximum number of pages per segment?  Answer Q 9:

a. 22 = 4 segments b. 216+8 = 224 c. 28

(9)

Question # 10:

Assume a hardware mechanism using a combined segmentation and paging. The user logical address space can have up to 8 segments of 64KB each. Each segment can have up to 64 pages of 1024 bytes each. Given a 4-segment user program P (S0: 4000 bytes, S1: 4000 bytes, S2: 4000 bytes, S3: 4000 bytes) and the free frame list is {12, 23, 32, 45, 57, 64, 72, 81, 99, 103, 120, 124, 108, 90, 85, 78, 67, 55, 46, 33, 25, 16, 8, 27, 38, 49, 51, 62}

Translate the following 1-dimensional logical addresses 6452 and 12846 into 1-dimensional physical addresses after performing memory allocation.

 Answer Q 10: 4000 / 1024 = 4 pages S0 need 4 pages {12, 23, 32, 45} S1 need 4 pages {57, 64, 72, 81} S2 need 4 pages {99, 103, 120, 124} S3 need 4 pages {108, 90, 85, 78} Logical address 6452 • 4000 < 6452 < 7999  € S1 • 6452 – 4000 = 2452  < S1, 2452>

• Page number is (2452 / 1024 = 2) , address in page #2 is (2452 - 1024*2 = 404)  <2, 404> • <2,404> change to frame #  <2,404> = <72,404>

• Physical address = 72 * 1024 + 404 = 74132

Logical address 12846

• 12000 < 12846 < 15999  € S3 • 12846 – 12000 = 846 <S3, 846>

• Page number is (846 / 1024 = 0), address in page #0 is (846 – 1024 * 0)  <0, 846> • <0, 846> change to frame # <0, 846> = <108, 846>

References

Related documents

Service Group 1 Control Plane Video Plane On-Demand Content Internet STB PC EdgeQAM Core CMTS DOCSIS Encapsulation Live Source Service Group 1 Control Plane Video Plane VOD

Very high resolution satellite data (Ikonos) was classified using both supervised and object oriented classification techniques.. A combination of spectral, spatial attributes

They will either be almost entirely descriptive with few explicit links to the question or they will provide some explanations backed by evidence that is limited in

A Fuzzy Analytical Network Process (FANP) was then proposed to weight the extracted measures and determine their importance level.. The model was then implemented to

Independence: Considering the demands laid down in the Swedish Corporate Governance Code regarding the Board’s independence and that Olof Persson is the President of AB Volvo and

We observe similar results for shorter windows around lockup expiry as mean CAARs are higher for IPOs with lockups longer than median relative to IPOs with

In more than 3,000 development partnerships with business – also known as public-private partnerships (PPP) – in more than 70 developing countries, primarily German companies, with

information must be specified Neutralization reaction Oxidation- reduction reactions Reaction of hydrolysis and saponification Reactions of double replacement