You are on page 1of 2

National University of Sciences & Technology

School of Electrical Engineering and Computer Science


Department of Computing
CS 330: Operating System (3+1): BSCS7 Fall 2019
Assignment 3/Lab 12
CLO Mapping:
CLO-4 Develop programs to interact with OS components through its API
CLO-2 Analyze the applicability of different OS Algorithms
Maximum Marks: 10 Instructor: Dr. Pakeeza Akram
Announcement Date: 10/12/2019 Due Date: 10/12/2019

Instructions:

 You can work in group of maximum three students. Individual or pairs are also allowed.
 This assignment is due today till at the end of respective session.
 No late assignment is acceptable.

Deliverable:

You need to submit code and screen shots with detail summary of the working of code.
There will be two files by each group.
1. code file
3. Summary, input and output and screenshots.

Tasks

1. Assume that a system has 32-bit virtual address with a 4-KB page size. Write a C program that
is passed a virtual address (in decimal) on the command line and have it output the page number
and offset for the given address. As an example, your program would run as follows:
./a.out 19986
Your program would output:
The address 19986 contains:
Page number= 4
Offset = 3602
Hint: you need use appropriate data type such as unsigned int.

2. Write a program that implements the FIFO, LRU and optimal page replacement algorithms.
First generate a random page-reference string where page numbers range from 0-9. Apply the
random page reference string to each algorithm and record the number of page faults incurred by
each algorithm. Implement the replacement algorithms so that the number of page frames can
vary from 1 to 7. Assume that demand paging is used.

You might also like