OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 4:23 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: paging poc
PostPosted: Fri Jun 04, 2021 4:12 pm 
Offline

Joined: Sat May 01, 2021 8:47 pm
Posts: 15
any poc of x64 paging? im struggling


Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Fri Jun 04, 2021 10:14 pm 
Offline
Member
Member
User avatar

Joined: Sun Feb 18, 2007 7:28 pm
Posts: 1564
Hi,

You might get faster responses if you gave us an idea of what you were not sure about with respect to paging. It may also be helpful for you to describe how you believe paging works so that we can discuss any potential issues with respect to understanding. We can probably make some guesses, however am sure many people here will be willing to help clarify any doubts on the subject matter. Paging is one topic where understanding how it works is critical to being able to successful implement and work with it: if you are trying to copy from a tutorial here, dont: know how it works before writing any code.

You might get lucky with getting a poc, not sure -- but a lot of folks here are happy to provide help if you provide us some details to work with.

_________________
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}


Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Sat Jun 05, 2021 5:32 pm 
Offline
User avatar

Joined: Tue Mar 16, 2021 2:00 pm
Posts: 11
I'm also unsure how paging works.

_________________
Image

Plan 9 | ReactOS Hybrid Kernel_Preview
http://woodmann.com/fravia/godwin1.htm


Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Sat Jun 05, 2021 10:23 pm 
Offline
Member
Member

Joined: Wed Aug 30, 2017 8:24 am
Posts: 1593
Skyz wrote:
I'm also unsure how paging works.
Again, this is way too open-ended a question to be answered in any meaningful way. I could read the manual to you, but you could also just do that on your own time. What specific thing are you having a problem with? Because as it stands now it looks like you didn't even try to read the documentation.

_________________
Carpe diem!


Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Sun Jun 06, 2021 5:19 pm 
Offline

Joined: Sat May 01, 2021 8:47 pm
Posts: 15
nullplan wrote:
Skyz wrote:
I'm also unsure how paging works.
Again, this is way too open-ended a question to be answered in any meaningful way. I could read the manual to you, but you could also just do that on your own time. What specific thing are you having a problem with? Because as it stands now it looks like you didn't even try to read the documentation.


I read SDM, but I'd use SDM and a POC better to understand..

Do I have to make a frame for everything or just what i wanna page, is there any alternative to paging?


Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Sun Jun 06, 2021 7:10 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
newosdeveloper2021 wrote:
Do I have to make a frame for everything or just what i wanna page,

What do you mean? In long mode, all physical memory is divided into frames. If you want to access one of those frames, you have to map it to a page to give it a virtual address.

newosdeveloper2021 wrote:
is there any alternative to paging?

No. Paging is mandatory in long mode.


Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Mon Jun 07, 2021 12:20 pm 
Offline
User avatar

Joined: Tue Mar 16, 2021 2:00 pm
Posts: 11
Octocontrabass wrote:
newosdeveloper2021 wrote:
Do I have to make a frame for everything or just what i wanna page,

What do you mean? In long mode, all physical memory is divided into frames. If you want to access one of those frames, you have to map it to a page to give it a virtual address.

newosdeveloper2021 wrote:
is there any alternative to paging?

No. Paging is mandatory in long mode.


Can you just make a new mode like short mode and avoid paging?

_________________
Image

Plan 9 | ReactOS Hybrid Kernel_Preview
http://woodmann.com/fravia/godwin1.htm


Last edited by Skyz on Mon Jun 07, 2021 12:25 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Mon Jun 07, 2021 12:42 pm 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 am
Posts: 401
Skyz wrote:
Is there a mode that it can be avoided, what's the benefit of running paging. I don't see any os using applications.


x86 protected mode doesn't use paging until it is explicitly enabled, so basic real mode and protected mode can both be used without paging.

But paging brings massive benefits:

- Simplifies process separation. With a page table per isolated address space, it is easy to control what memory is exclusively or shared mapped at a per-page per process level.
- Simplifies memory allocation. For a process logical address space, the allocated physical memory can be anywhere, it need not be contiguous. This is the basis of virtual memory, and is very difficult to do with segmentation, because contiguous virtual memory also has to be contiguous in physical memory using base/limit segmentation.
- Reduces memory usage. Because virtual memory pages can be unmapped, and mapped in on demand, not all memory a process needs has to be actually resident. Demand paging allocates memory to address spaces as it's needed, and a process rarely needs all its memory all of the time, so some can be discarded when not in use and (re-)read from disk as required.

Personally, I see paging and virtual memory management as considerably more useful and fundamental for operating systems than, for example, file systems. A minimal kernel needs to implement, if it is providing protected address spaces at all, a paging mechanism. The only systems that don't are simple embedded kernels, which provide essentially a threaded runtime to some dedicated application, which might not even have a MMU. Think IoT.

Otherwise, for a general purpose kernel, paging is fundamental, and no general purpose CPUs in common use (except x86) provide anything other than a page based MMU. Even single address space kernels benefit from paging if the CPU provides it.


Top
 Profile  
 
 Post subject: Re: paging poc
PostPosted: Mon Jun 07, 2021 12:52 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5099
Skyz wrote:
Can you just make a new mode like short mode and avoid paging?

You can't make a new mode. You can use real mode or protected mode if you want to avoid paging. Why do you want to avoid paging?


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], DotBot [Bot] and 69 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