coding_assignment_3 COMSC 260 Applied Operating Systems Spring 2021 Coding Assignment #3, Due: 11:59 PM on Tuesday, May 4, 2021 Grading: up to 15% of the course’s final grade including bonus points...

1 answer below »
coding_assignment_3


COMSC 260 Applied Operating Systems
Spring 2021
Coding Assignment #3,
Due: 11:59 PM on Tuesday, May 4, 2021
Grading: up to 15% of the course’s final grade including bonus points
Submission: submit to Bridges a zip or a tgz file that comprises your source code and
three sample outputs including the default one


Description
Write a program that implements the LRU page-replacement algorithms presented in
chapter 8.
Two implementation options are described in Section 8.4.4:
1. Counters
2. Stack
You can choose either of the options. However, if you use stack and implement the
algorithm correctly, you’ll get 5 bonus points.
Requirement
• Your submitted source code must be free of error or warning while compiling.
• Without any command line parameters, your program should by default process a
hard-coded page reference string [ XXXXXXXXXX XXXXXXXXXX] with 3
memory frames (refer to Figure 8.15).
• Your program should take the following parameters from command line:
o The number of frames
o The number of pages
o A reference string (optional)
When the number of pages is passed in, your program will randomly generate a
reference string with the number of pages specified.
• Your program must print out the number of faults incurred at the end.
• Assume page numbers range from 0 to 9.
• Assume that demand paging is used.
Sample output
Default:
$ ./lru

# Use hard coded parameters:
# Number of frames: 3
# Reference string: [ XXXXXXXXXX XXXXXXXXXX]
____________________________________________________________________

7 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
0 FAULT [ XXXXXXXXXX ] [ 7 0 -1 ]
1 FAULT [ 7 0 -1 ] [ 7 0 1 ]
2 FAULT [ 7 0 1 ] [ 0 1 2 ]
0 HIT [ 0 1 2 ] [ 1 2 0 ]
3 FAULT [ 1 2 0 ] [ 2 0 3 ]
0 HIT [ 2 0 3 ] [ 2 3 0 ]
4 FAULT [ 2 3 0 ] [ 3 0 4 ]
2 FAULT [ 3 0 4 ] [ 0 4 2 ]
3 FAULT [ 0 4 2 ] [ 4 2 3 ]
0 FAULT [ 4 2 3 ] [ 2 3 0 ]
3 HIT [ 2 3 0 ] [ 2 0 3 ]
2 HIT [ 2 0 3 ] [ 0 3 2 ]
1 FAULT [ 0 3 2 ] [ 3 2 1 ]
2 HIT [ 3 2 1 ] [ 3 1 2 ]
0 FAULT [ 3 1 2 ] [ 1 2 0 ]
1 HIT [ 1 2 0 ] [ 2 0 1 ]
7 FAULT [ 2 0 1 ] [ 0 1 7 ]
0 HIT [ 0 1 7 ] [ 1 7 0 ]
1 HIT [ 1 7 0 ] [ 7 0 1 ]

*** Total Page Faults: 12 ***

Randomly generated Reference String:
$ ./lru -f 4 -p 15
# Use a randomly genearted reference string:
# Number of frames: 4
____________________________________________________________________

3 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
6 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
7 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
5 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
3 HIT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
5 HIT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
6 HIT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
2 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
9 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
1 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
2 HIT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
7 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
0 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
9 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
3 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]

*** Total Page Faults: 11 ***

Passed-in Reference String from command line:
$ ./lru -f 3 -r " XXXXXXXXXX XXXXXXXXXX"
Use command line parameters:
# Number of frames: 3
# Reference string: [ XXXXXXXXXX XXXXXXXXXX]
____________________________________________________________________

7 FAULT [ XXXXXXXXXX ] [ XXXXXXXXXX ]
0 FAULT [ XXXXXXXXXX ] [ 7 0 -1 ]
1 FAULT [ 7 0 -1 ] [ 7 0 1 ]
2 FAULT [ 7 0 1 ] [ 0 1 2 ]
0 HIT [ 0 1 2 ] [ 1 2 0 ]
3 FAULT [ 1 2 0 ] [ 2 0 3 ]
0 HIT [ 2 0 3 ] [ 2 3 0 ]
4 FAULT [ 2 3 0 ] [ 3 0 4 ]
2 FAULT [ 3 0 4 ] [ 0 4 2 ]
3 FAULT [ 0 4 2 ] [ 4 2 3 ]
0 FAULT [ 4 2 3 ] [ 2 3 0 ]
3 HIT [ 2 3 0 ] [ 2 0 3 ]
2 HIT [ 2 0 3 ] [ 0 3 2 ]
1 FAULT [ 0 3 2 ] [ 3 2 1 ]
2 HIT [ 3 2 1 ] [ 3 1 2 ]
0 FAULT [ 3 1 2 ] [ 1 2 0 ]
1 HIT [ 1 2 0 ] [ 2 0 1 ]
7 FAULT [ 2 0 1 ] [ 0 1 7 ]
0 HIT [ 0 1 7 ] [ 1 7 0 ]
1 HIT [ 1 7 0 ] [ 7 0 1 ]

*** Total Page Faults: 12 ***
Answered Same DayMay 03, 2021COMSC 260

Solution

Sandeep answered on May 04 2021
28 Votes

Submit New Assignment

Copy and Paste Your Assignment Here