OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 3:57 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Page/Swap/RAM File Implementation
PostPosted: Tue Aug 23, 2022 7:08 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
As far as I know, the page file is used to extend the RAM by temporarely storing unused RAM to the disk. Marking each page as paged and loading it when a page fault occurs.

- How systems choose pages to be paged
- RAM extension using a Paging File doesn't seem to be safe and in a (brute force) case it will slow/freeze/panic the operating system.
- Memory Management Question : the FreePool() or free() function must search through a list of memory/heap segments, a (page table scheme) will be much faster but so ineffective.

- Unused memory is selected by going through the page tables and checking the accessed bit and the dirty bit to write new content to the page file
- Do you recommand loading page by page or loading the entire heap from the page file ?


Top
 Profile  
 
 Post subject: Re: Page/Swap/RAM File Implementation
PostPosted: Mon Aug 29, 2022 3:35 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5100
devc1 wrote:
- How systems choose pages to be paged

The OS tracks how recently each page was accessed. Pages that haven't been accessed recently will be moved to the disk if the OS runs out of free RAM.

devc1 wrote:
- RAM extension using a Paging File doesn't seem to be safe and in a (brute force) case it will slow/freeze/panic the operating system.

Out-of-memory conditions can cause a freeze or panic even without paging to disk. You're right about the disk being slower than RAM, though.

devc1 wrote:
- Memory Management Question : the FreePool() or free() function must search through a list of memory/heap segments, a (page table scheme) will be much faster but so ineffective.

That's not a question.

devc1 wrote:
- Unused memory is selected by going through the page tables and checking the accessed bit and the dirty bit to write new content to the page file

Correct. On architectures that don't provide these bits, you can emulate them by removing read or write permissions and waiting for page faults.

devc1 wrote:
- Do you recommand loading page by page or loading the entire heap from the page file ?

You know you can swap any page to disk, not just pages that are part of the heap, right? Anyway, it's a trade: loading many pages means fewer disk accesses if the program accesses all of the pages you load, but it means extra time spent waiting for the disk if the program doesn't access the extra pages that you load.


Top
 Profile  
 
 Post subject: Re: Page/Swap/RAM File Implementation
PostPosted: Mon Aug 29, 2022 6:00 pm 
Offline
Member
Member

Joined: Sat Feb 04, 2012 5:03 pm
Posts: 111
Linux, Windows and macOS also compress memory. As in, "swap" it to a different part of RAM and compress it.

https://docs.kernel.org/admin-guide/blockdev/zram.html

https://superuser.com/questions/1383484 ... windows-10

https://support.apple.com/guide/activit ... tr1004/mac (search for "compressed memory")


Top
 Profile  
 
 Post subject: Re: Page/Swap/RAM File Implementation
PostPosted: Mon Aug 29, 2022 7:23 pm 
Offline
Member
Member

Joined: Fri Feb 11, 2022 4:55 am
Posts: 435
Location: behind the keyboard
Nice idea, I will implement it too


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Majestic-12 [Bot] and 54 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group