Linux - KernelThis forum is for all discussion relating to the Linux kernel.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
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.
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.
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.