LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
LinkBack Search this Thread
Old 03-31-2007, 06:34 PM   #1
Midraga
LQ Newbie
 
Registered: Jul 2003
Location: Cambera
Distribution: RedHat 9
Posts: 5

Rep: Reputation: 0
Newbie kernel internals memory addressing


Hi,

I am reading book "Understanding Linux Kernel" and came across a paragraph that says:

"Because a Segment Descriptor is 8 bytes long, its relative address inside the GDT or the LDT is obtained by multiplying the 13-bit index field of the Segment Selector by 8. For instance, if the GDT is at 0x00020000 (the value stored in the gdtr register) and the index specified by the Segment Selector is 2, the address of the corresponding Segment Descriptor is 0x00020000 + (2 x 8), or 0x00020010."

Can someone please explain how did the author calculate the number? I would expect end result to be 0x00020016. And also what 0x stands for?

Please excuse me if I am asking rally dumb questions but I rally want to learn this stuff.

Cheers,

Midraga
 
Old 03-31-2007, 06:45 PM   #2
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 10,448

Rep: Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622
That text is discussing hexadecimal values - base 16 rather than base 10 (decimal) we are used to in "normal" usage. That's what the "0x" is indicating.
You *really* need to get your head around binary (and by association octal and hexadeximal) number representations before you get too frustrated with the depth that books discusses.
I'm heading out the door, but hopefully some-else will chime in with a link for an online tutorial.
 
Old 03-31-2007, 06:49 PM   #3
Lenard
Senior Member
 
Registered: Dec 2005
Location: Indiana
Distribution: RHEL/CentOS/SL 5 i386 and x86_64 pata for IDE in use
Posts: 4,790

Rep: Reputation: 56
0x == hex

FYI: the value in the book is correct, 0x10 = 16 (base ten)
 
Old 03-31-2007, 07:01 PM   #4
Midraga
LQ Newbie
 
Registered: Jul 2003
Location: Cambera
Distribution: RedHat 9
Posts: 5

Original Poster
Rep: Reputation: 0
Re

Hi Guys,

Thank you for prompt reply, I didn't expect anything this fast

I will have look at some hex, octal and binary tutorials. Any useful links that you might have would be very useful.

Cheers,

Midraga
 
Old 04-04-2007, 08:07 PM   #5
sundialsvcs
Senior Member
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 3,681

Rep: Reputation: 329Reputation: 329Reputation: 329Reputation: 329
Hex, octal, and binary are easy to grok ...

Hexadecimal numbers correspond to groups of four bits. There are sixteen numbers from 0 to 9, A to F. A leading '$' or '0x' is often used as a convention to indicate a hexadecimal number.

Octal numbers correspond to groups of three bits, numbers 0 to 7. Since a byte is normally eight bits long, a number consisting of eight '1's would be written: '0377.' (A leading zero (or '0o') is often, but not always, used as a convention to indicate an octal number.)

Binary numbers correspond to groups of one bit ... numbers '0' and '1'.

In all cases, if the number is understood to be of a certain width (in bits), and fewer than the required number of digits are specified, the value is understood to be right-justified; that is to say, the value is padded on the left-hand side with zeroes.
 
Old 04-04-2007, 09:07 PM   #6
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 10,448

Rep: Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622Reputation: 622
Whilst true, that probably means nothing to some-one trying to learn this for the first time.
Quote:
there are 10 types of people - them what understand binary, and them what don't
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel Internals - customizing 2.6 builds bgeddy Slackware 5 11-01-2006 11:08 AM
see linux kernel internals nocturna_gr Linux - General 4 07-05-2005 06:15 PM
Addressing 36-bits of memory from single process using Xeon processor clustopher Slackware 1 02-24-2005 10:37 AM
Linux Kernel Internals altosys Programming 10 07-24-2004 03:13 PM
Linux kernel internals RussoIsraeli Linux - General 2 11-02-2003 09:11 PM


All times are GMT -5. The time now is 12:41 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration