View
4
Download
0
Category
Preview:
Citation preview
CSCI-3753: Operating SystemsFall 2018
Anh NguyenDepartment of Computer Science University of Colorado Boulder
Week 12: PA 4
CSCI 3753 Fall 2018 2
Assignment Goal
CSCI 3753 Fall 2018 3
• Implement a paging strategy that a paging simulator can use to maximize the performance of the memory access in a set of pre-defined programs
•Action items• Implement LRU algorithm • pager-lru.c
• Implement any form of predictive paging algorithm• pager-predict.c
Source Code
CSCI 3753 Fall 2018 4
• Github code:https://github.com/asayler/CU-CS3753-PA4
•Note:• simulator.c has been updated for this assignment• If you use code from github, be sure to update line 68 as
follows:
static inline void assert(int boolean,char *boolstr, char *file, int line)
Paging Simulator
CSCI 3753 Fall 2018 5
•Run a random set of 5 pre-defined programs utilizing a limited number of shared physical pages
•Provide default values in simulator.h• 20 virtual pages per process (MAXPROCPAGES) • 100 physical pages (frames) in total (PHYSICALPAGES) • 20 simultaneous processes competing for pages
(MAXPROCESSES) • 128 memory unit page size (PAGESIZE) • 100 tick delay to swap a page in or out (PAGEWAIT)• Each instruction or step in the simulated programs requires 1 tick
to complete.
Paging Simulator
CSCI 3753 Fall 2018 6
•Provide 3 functions for interaction
•To control the allocation of virtual and physical pages• pagein()• pageout()
•To handle the page fault• pageit() ß core paging function that needs implementation
•Source code is provided.• simulator.h, simulator.c• pager-basic.c, pager-lru.c, pager-predict.c
pager-basic.c
CSCI 3753 Fall 2018 7
•A basic “one-process-at-a-time” implementation•A simple demonstration of the simulator API
•DON’T need any implementation from YOU !!!
pager-basic.c
CSCI 3753 Fall 2018 8
Your paging strategy mostly goes to this part.Select a Process
Determine Current Page
(pc / PAGESIZE)
Exit pageit()
Select aPage to Evict
Is Page Swapped In?
Remaining Processes?
Call pagein()
Call pageout()
Investigate Error
Simulator calls pageit()
Yes
Yes
No
No
Success
Failure
Failure
Success
pager-basic.c
Select a ProcessDetermine
Current Page(pc / PAGESIZE)
Exit pageit()
Select aPage to Evict
Is Page Swapped In?
Remaining Processes?
Call pagein()
Call pageout()
Investigate Error
Simulator calls pageit()
Yes
Yes
No
No
Success
Failure
Failure
Success
pager-lru.c
CSCI 3753 Fall 2018 10
Spend most of your time deciding how to implement itSelect a Process
Determine Current Page
(pc / PAGESIZE)
Exit pageit()
Select aPage to Evict
Is Page Swapped In?
Remaining Processes?
Call pagein()
Call pageout()
Investigate Error
Simulator calls pageit()
Yes
Yes
No
No
Success
Failure
Failure
Success
pager-lru.c
Select a ProcessDetermine
Current Page(pc / PAGESIZE)
Exit pageit()
Select aPage to Evict
Is Page Swapped In?
Remaining Processes?
Call pagein()
Call pageout()
Investigate Error
Simulator calls pageit()
Yes
Yes
No
No
Success
Failure
Failure
Success
pager-predict.c
CSCI 3753 Fall 2018 12
•Require a predictive algorithm that• Attempts to predict what pages each process will require
in the future and then
• Swaps these pages in before they are needed
• Note: In any predictive operation, you ideally wish to stay 100-200 ticks ahead of the execution of each process.
pager-predict.c
CSCI 3753 Fall 2018 13
Spend most of your time deciding how to implement it
Select a Process
Determine Current Page
(pc / PAGESIZE)
Exit pageit()
Select aPage to Evict
Is Page Swapped In?
Remaining Processes?
Call pagein()
Call pageout()
Investigate Error
Simulator calls pageit()
Yes
Yes
No
No
Success
Failure
Failure
Success
DetermineFuture Page(More Magic)
Repeat 2x for Both Current and Future Paths
Check for Previous Prediction Miss
Attempt to Setup Future Prediction Hit
pager-predict.c
Select a Process
Determine Current Page
(pc / PAGESIZE)
Exit pageit()
Select aPage to Evict
Is Page Swapped In?
Remaining Processes?
Call pagein()
Call pageout()
Investigate Error
Simulator calls pageit()
Yes
Yes
No
No
Success
Failure
Failure
Success
DetermineFuture Page(More Magic)
Repeat 2x for Both Current and Future Paths
Check for Previous Prediction Miss
Attempt to Setup Future Prediction Hit
Week 12 – Checklist
q Discuss PS3q Discuss PA4
CSCI 3753 Fall 2018 15
Recommended