DEV Community

kavyareddysureddy
kavyareddysureddy

Posted on

PAGING IN OPERATING SYSTEM

PAGE REPLACEMENT:
->Prevent over-allocation of memory by modifying page-fault service routine to include page replacement
->Use modify (dirty) bit to reduce overhead of page transfers – only modified pages are written to disk

->Page replacement completes separation between logical memory and physical memory – large virtual memory can be provided on a smaller physical memory

Basic Page Replacement:
1.Find the location of the desired page on disk
2.Find a free frame:
-If there is a free frame, use it
-If there is no free frame, use a page replacement algorithm to select a victim frame
-Write victim frame to disk if dirty
3.Bring the desired page into the (newly) free frame; update the page and frame tables
4.Continue the process by restarting the instruction that caused the trap

=>Note now potentially 2 page transfers for page fault – increasing EAT

Page and Frame Replacement Algorithms:
=>Frame-allocation algorithm determines
-How many frames to give each process
-Which frames to replace
=>Page-replacement algorithm
-Want lowest page-fault rate on both first access and re-access
=>Evaluate algorithm by running it on a particular string of memory references (reference string) and computing the number of page faults on that string
-String is just page numbers, not full addresses
-Repeated access to the same page does not cause a page fault

-Results depend on number of frames available

Page Replacement Algorithms:
-FIFO
-OPTIMAL REPLACEMENT
-LRU REPLACEMENT

-SECOND CHANCE PAGE REPLACEMENT

-FIFO:First In First Out (FIFO) –
This is the simplest page replacement algorithm. In this algorithm, the operating system keeps track of all pages in the memory in a queue, the oldest page is in the front of the queue. When a page needs to be replaced page in the front of the queue is selected for removal.
-OPTIMAL REPLACEMENT:
In this algorithm, pages are replaced which would not be used for the longest duration of time in the future.
-LRU REPLACEMENT:
Least Recently Used –In this algorithm page will be replaced which is least recently used.
-SECOND CHANCE PAGE REPLACEMENT:
the Second Chance replacement policy is called the Clock replacement policy.
In the Second Chance page replacement policy, the candidate pages for removal are consider in a round robin matter, and a page that has been accessed between consecutive considerations will not be replaced.The page replaced is the one that - considered in a round robin matter - has not been accessed since its last consideration.

Sentry image

Hands-on debugging session: instrument, monitor, and fix

Join Lazar for a hands-on session where you’ll build it, break it, debug it, and fix it. You’ll set up Sentry, track errors, use Session Replay and Tracing, and leverage some good ol’ AI to find and fix issues fast.

RSVP here →

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs