15
CSCI-3753: Operating Systems Fall 2018 Anh Nguyen Department of Computer Science University of Colorado Boulder

CSCI-3753: Operating Systems Fall 2018

  • Upload
    others

  • View
    3

  • Download
    0

Embed Size (px)

Citation preview

Page 1: CSCI-3753: Operating Systems Fall 2018

CSCI-3753: Operating SystemsFall 2018

Anh NguyenDepartment of Computer Science University of Colorado Boulder

Page 2: CSCI-3753: Operating Systems Fall 2018

Week 12: PA 4

CSCI 3753 Fall 2018 2

Page 3: CSCI-3753: Operating Systems Fall 2018

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

Page 4: CSCI-3753: Operating Systems Fall 2018

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)

Page 5: CSCI-3753: Operating Systems Fall 2018

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.

Page 6: CSCI-3753: Operating Systems Fall 2018

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

Page 7: CSCI-3753: Operating Systems Fall 2018

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 !!!

Page 8: CSCI-3753: Operating Systems Fall 2018

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

Page 9: CSCI-3753: Operating Systems Fall 2018

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

Page 10: CSCI-3753: Operating Systems Fall 2018

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

Page 11: CSCI-3753: Operating Systems Fall 2018

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

Page 12: CSCI-3753: Operating Systems Fall 2018

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.

Page 13: CSCI-3753: Operating Systems Fall 2018

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

Page 14: CSCI-3753: Operating Systems Fall 2018

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

Page 15: CSCI-3753: Operating Systems Fall 2018

Week 12 – Checklist

q Discuss PS3q Discuss PA4

CSCI 3753 Fall 2018 15