click here to

advertisement

Lab Guide – Operating System

Assignment 1: Physical & Logical Address a) Calculate the number of bits required to access the memory location of 1024 KBytes.

Assume every location is of 1 Byte in length. b) If the size of the memory is now increased to 1024 Mbytes, calculate the number of bits required to address each memory location

Summary of this assignment:

The number of address lines is decided by the size of the total memory available in the system. Every memory location is normally 8 bits or 1 Byte in width. So the number of address lines required for addressing ‘N’ locations is log2 N. to store data.

Assignment 2: Page Number and Page Offset

1. Consider a paging scheme with page size equal to 1 KBytes. The total size of the file is equal to 1 Mbytes. Calculate the total number of bits required in logical address.

2. What will be Logical address of the location 5123 in a paging scheme where the page size is 2Kbytes and the total size of the file is 10240 Bytes?

Summary of this assignment:

The paging address has two components, page address and the offset (displacement).

The number of pages required for a program depends on the size of the program. The number of bits required to address the ‘N’ different pages is log2N. For example if the size of each page is 1 K Bytes and the size of the program is 10 K Bytes, then the number of pages required is 10.The Size of the page decides the number of bits required for the offset.

Assignment 3: Page Replacement Algorithms

1. The following are the page numbers which are requested in demand paging:

2 3 4 1 5 3 4 2 3 4 4 1

Given that the main memory has 3 frames, calculate the number of page faults that would occur for FIFO algorithm. Assume that initially none of the pages are in main memory.

2. The following are the page numbers which are requested in demand paging:

1 2 3 4 1 5 3 6 7 2 3 3 5 2 2 7 4 4 1

Given that the main memory has 4 frames. Calculate the number of page faults that would occur for FIFO algorithm. Assume that initially none of the pages are in main memory.

3. Consider a dynamic paging scheme, where the page numbers and request sequence is as follows:

3 1 5 4 2 7 1 5 61 2 7 1 2 3 6 5 4 7 6 5 1 4 5 3 1 6

Given that the main memory has 3 frames, calculate the number of page faults that would occur. Assume that initially the first 3 pages (3, 1 and 5) are in main memory. a) Solve the above problem using FIFO page replacement algorithm. b) Solve the above problem using LFU algorithm. Consider the FIFO algorithm to replace the page in case of any tie. c) Solve problem (a) for the Most Frequently Used algorithm. (Replace the page which is used most frequently used) d) Solve problem (a) considering total of 4 frames in memory and that the initial 4 pages are pre-fetched into the memory. Analyze the difference.

4. Consider a dynamic paging scheme, where the page numbers and request sequence is as follows:

1 1 3 1 1 6 4 2 3 5 1 7 2 5 3 6 4 7 3 4 2 7 6

Given that the total number of frames in the memory is 5 and that the first two frames are loaded with pages 1 and 3, calculate the number of page faults that occur when the

LRU algorithm is used.

5. Solve the above problem using Most Recently Used algorithm (the page which has been used recently will be replaced by the incoming page).

Assignment 4: Process Scheduling

1. Calculate Average Waiting time, Average turnaround time, Average response time for a) FCFS b) SJF c) SRT d) Round robin time slice=3. e) Draw flow chart using Raptor tool for FCFS scheduling to calculate the average waiting time & turnaround time (assume arrival time 0 for all processes)

Hint: input total number of processes and CPU time for each process

Process

P1

P2

P3 p4 p5

Arrival Time

0

0

1

4

2

CPU Time

6

10

4

10

12

2. Calculate Average Waiting Time, Average Turn Around Time and Average response time for a) Priority based preemptive b) Priority based Non preemptive scheduling

Process CPU Time Priority

P1

P2

P3 p4 p5

4

1

2

Arrival

Time

0

7

6

10

4

10

12

2

1

3

2

0

3. Calculate Average Waiting time, Average response time for a) SRT b) Round robin time slice=6. c) Round robin time slice=3. d) Preemptive priority scheduling

P1

P2

P3 p4 p5 e) Non-preemptive priority scheduling

Process Arrival Time CPU Time

0 6

4 1

1

3

3

3

2

8

Priority

2

1

3

2

3

P6

P7

P8

4

5

5

6

7

6

1

4

3

4. Calculate Average Waiting time, Average turnaround time, Average response time for a) SRT b) Round robin time slice=4. c) FCFS

Process

X

Y

Z

Arrival Time

1

0

1

CPU Time

4

6

3

Assignment 5: Disk Scheduling

1. Calculate Average Seek Time.

Disk queue:

50, 185, 100, 145, 75, 30, 190, 60, 78, 15, 98, 37

Given that there are 300 cylinders numbered from 0-299 and the disk head starts at number 150. a. FCFS Scheduling b. SSTF Scheduling c. SCAN Scheduling d. C-SCAN Scheduling e. LOOK Scheduling

Self Review:

1. Which of the following memory management schemes does not lead to internal fragmentation? a. Simple paged allocation b. Demand Paging c. Variable partition memory allocation

2. Calculate the average waiting time with respect to preemptive shortest job first scheduling algorithm

Process Arrival

Time

CPU Time

P1

P2

P3 a. 5 b. 6 c. 4 d. 7

0

4

8

25

10

4

3. The following are the page numbers which are requested:

3 1 3 4 2 4

Given that the main memory has 2 frames calculate the number of page faults that would occur. Assume that initially none of the pages are in main memory and LFU algorithm is used for page replacement.

a. 4 b. 6 c. 3 d. 5

4. Calculate the average waiting time with respect to round robin scheduling algorithm.

The time slice is 8ms.

Process CPU Time

P1

P2

P3

12

10

5

5. The following are the page numbers which are requested :

1 2 3 4

Given that the main memory has 4 frames calculate the number of page faults that would occur. Assume that initially none of the pages are in main memory and LRU algorithm is used for page replacement. a. 0 b. 3 c. 2 d. 4

6. What is the difference, if any, between context switching and scheduling?

7. What kind of data structure is required to implement the round-robin scheduling policy?

8. In round robin scheduling, what happens if the time slice is too large? Identify the advantages and disadvantages.

9. Find the average waiting time in the round robin scheduling for the following.

Assume a time slice of 4ms.

Process CPU Time

P1

P2

P3

24

3

3

Download