Query about GDT entries

OS Design, Theory, and Programming

Moderator: Moderators

Query about GDT entries

Postby Andyhhp » Mon Jan 21, 2008 11:49 am

I have a query that is not clear in the tutorials.

In the GDT, there are 32 bits for the base address but only 20 bits for the limit.

As 2^32 is 4GB, I can see that it is possible to have a segment starting anywhere in memory.

However, only having 20 bits for the limit doesn't allow you to have a segment that extends along all of memory if the limit references individual bytes.

My question is: Does the limit refer to individual bytes or does it refer to 4KB sections. i.e. if you set the base to 0 and the limit to 1, you would be able to address the first 4KB of linear memory. (4KB because its the default page size and because 1MB * 4KB = 4GB).

Thanks,

Andrew
Image
Andyhhp
Moderator
 
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1

Re: Query about GDT entries

Postby oib111 » Sat Aug 29, 2009 6:48 am

The limit refers to a physical address. But if you look at the bit layout of the GDT you see that bit 55 (granularity) determines whether or not the segment limit is multiplied by 4K or not (granularity bit has to be set to 1 for that to happen). This makes your equation true because the limit is 1MB, but if bit 55 is set it is multiplied by 4K and this allows for a segment limit of up to 4GB (as shown in your equation).
oib111
 
Posts: 38
Joined: Sat Aug 29, 2009 6:44 am

Re: Query about GDT entries

Postby Andyhhp » Sat Aug 29, 2009 5:58 pm

hehe - 2 years late but thanks anyway :P
Image
Andyhhp
Moderator
 
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1

Re: Query about GDT entries

Postby oib111 » Sun Aug 30, 2009 3:02 am

Better knowing two years late than never knowing haha. Didn't realize it was a two year old post :P
oib111
 
Posts: 38
Joined: Sat Aug 29, 2009 6:44 am

Re: Query about GDT entries

Postby Andyhhp » Sun Aug 30, 2009 2:41 pm

spose - then again, i did find it out nearly 2 years ago :P
Image
Andyhhp
Moderator
 
Posts: 387
Joined: Tue Oct 23, 2007 10:05 am
Location: 127.0.0.1

Re: Query about GDT entries

Postby oib111 » Sun Aug 30, 2009 6:26 pm

Haha ok then. Didn't know that either :lol:
oib111
 
Posts: 38
Joined: Sat Aug 29, 2009 6:44 am


Return to Advanced OS Development

Who is online

Users browsing this forum: No registered users and 1 guest

cron