LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Protected mode (https://www.linuxquestions.org/questions/programming-9/protected-mode-801870/)

MTK358 04-13-2010 08:00 PM

Protected mode
 
I was wondering what exactly is protected mode, segmentation, and paging?

Do you know of any good explanations?

MrCode 04-13-2010 08:07 PM

This section of an "introduction to operating systems" guide has some info on segmentation/sharing and paging. IMO that guide is a fascinating read. :)

paulsm4 04-14-2010 09:42 AM

Hi -

Here's another good article:
http://www.internals.com/articles/pr...troduction.htm

Short explanation:
* "Protected mode" is the opposite of "Real Mode"

* "Protected mode" uses "virtual memory", which offers many, many benefits. "Real mode" accesses RAM directly, and has many, many limitations.

* DOS used to use "real mode" (because that's the only thing that existed on earlier Intel CPU's). Linux boots into "real mode" (to set up the low-level virtual memory configuration).

* "Real Mode" and "Protected mode" are Intel-specific terms. But virtually all general-purpose CPUs support "virtual memory" and, hence, generally run in the architecture equivalent of "real mode".

* Segmentation" is largely an artifact of "real mode": you can safely consider it an "anachronism" in assembly programming.

* "Pages" are an artifact of virtual memory ("protected mode").

* "Protected mode" is Good. "Real mode" not so much, most of the time.
Which is why a lot of DOS-oriented tutorials and tips on the web can actually be *misleading* to the novice assembly language programmer.

IMHO .. PSM

PS:
Did you resolve the 32-bit/64-bit issue in your "other thread"? Did you look up "multilib" yet?

PPS:
When you reference "another thread", it's helpful to provide a link.

You can do this with the little icon of a "globe-and-chain-link" in the toolbar at the top of your LQ response window, if you didn't already notice it. Just a suggestion :)

PPS:
Book recommendation:
"Professional Assembly Language", Richard Blum

Sergei Steshenko 04-14-2010 09:52 AM

Quote:

Originally Posted by paulsm4 (Post 3935349)
Hi -

Here's another good article:
http://www.internals.com/articles/pr...troduction.htm

Short explanation:
* "Protected mode" is the opposite of "Real Mode"

* "Protected mode" uses "virtual memory", which offers many, many benefits. "Real mode" accesses RAM directly, and has many, many limitations.

* DOS used to use "real mode" (because that's the only thing that existed on earlier Intel CPU's). Linux boots into "real mode" (to set up the low-level virtual memory configuration).

* "Real Mode" and "Protected mode" are Intel-specific terms. But virtually all general-purpose CPUs support "virtual memory" and, hence, generally run in the architecture equivalent of "real mode".

* Segmentation" is largely an artifact of "real mode": you can safely consider it an "anachronism" in assembly programming.

* "Pages" are an artifact of virtual memory ("protected mode").

* "Protected mode" is Good. "Real mode" not so much, most of the time.
Which is why a lot of DOS-oriented tutorials and tips on the web can actually be *misleading* to the novice assembly language programmer.

IMHO .. PSM

PS:
Did you resolve the 32-bit/64-bit issue in your "other thread"? Did you look up "multilib" yet?

PPS:
When you reference "another thread", it's helpful to provide a link.

You can do this with the little icon of a "globe-and-chain-link" in the toolbar at the top of your LQ response window, if you didn't already notice it. Just a suggestion :)

PPS:
Book recommendation:
"Professional Assembly Language", Richard Blum

Excellent explanation, Paul. By the way, ever thought of writing a good book on rhetorical questions ?

Sergei Steshenko 04-14-2010 10:00 AM

By the way, I think that segment registers in x86 are rather an attempt to have more than 16 bits of address space on what otherwise is a 16 bits CPU.

Nowadays the segment registers are longer and allow access to 16Gbytes of address space using still 32 bits CPU - the trick/approach is called PAE (Physical Address Extension); there are PAE enabled kernels (both Linux and Windows); works visibly slower.

salasi 04-14-2010 04:04 PM

Quote:

Originally Posted by paulsm4 (Post 3935349)
But virtually all general-purpose CPUs support "virtual memory"

Virtually all Microprocessors but the minority of Microcontrollers; so, did you mean Virtually all by numbers shipped, virtually all by value shipped, or virtually all by availability of type numbers? (Or you could change the word to microprocessors from CPUs.)

I can see what you meant, but I think that changes whether it is absolutely correct or not.

MTK358 04-15-2010 03:57 PM

I vaguely understand what segmentation and paging do, but I would like to know what the differences are?

How do you actually do segmentation/paging?

What are the registers involved?

Sergei Steshenko 04-15-2010 04:13 PM

Quote:

Originally Posted by MTK358 (Post 3936891)
I vaguely understand what segmentation and paging do, but I would like to know what the differences are?

How do you actually do segmentation/paging?

What are the registers involved?

Start from 8086 architecture/instruction set. By studying them you'll know what segment registers are and how/what for they are used by 8086 HW. 8086 does not have paging, so you task is easier.

MTK358 04-15-2010 04:15 PM

Quote:

Originally Posted by Sergei Steshenko (Post 3936908)
Start from 8086 architecture/instruction set. By studying them you'll know what segment registers are and how/what for they are used by 8086 HW. 8086 does not have paging, so you task is easier.

Where do I find a list of whatever CPU's commands and a description of what it does?

I tried googling with no luck.

Sergei Steshenko 04-15-2010 04:23 PM

Quote:

Originally Posted by MTK358 (Post 3936912)
Where do I find a list of whatever CPU's commands and a description of what it does?

I tried googling with no luck.

Try to visit intel.com - I guess it's the first logical step.

...

Regarding "no luck" - sorry, but I simply do not trust such statements of yours anymore. So far I know that you apparently stop after reading just first 5 lines of 'ld --help | less', i.e. you've arrived up to this place:

Code:

      1 Usage: ld [options] file...
      2 Options:
      3  -a KEYWORD                  Shared library control for HP/UX compatibility
      4  -A ARCH, --architecture ARCH
      5                              Set architecture

.

So, just try harder.

...

Have just rechecked myself by entering

8086 instruction set

into yahoo.com search - a lot of relevant links as a result.

ForzaItalia2006 04-15-2010 04:27 PM

Quote:

Originally Posted by MTK358 (Post 3936912)
Where do I find a list of whatever CPU's commands and a description of what it does?

I would recommend the ultimate guide :-) the Intel IA-32 / Intel 64 documentation at http://www.intel.com/products/processor/manuals/

There you'll find the COMPLETE instruction set described in every great detail. In Volume 1 and 3, IIRC, you should also find good descriptions of the different operating modes:

Volume 3a, Chapter 3: PROTECTED-MODE MEMORY MANAGEMENT
Volume 3a, Chapter 4: PAGING

That should contain all the information you need ... Happy reading :-D

- Andi -

MTK358 04-15-2010 04:47 PM

Quote:

Originally Posted by Sergei Steshenko (Post 3936925)
Try to visit intel.com - I guess it's the first logical step.

...

Regarding "no luck" - sorry, but I simply do not trust such statements of yours anymore. So far I know that you apparently stop after reading just first 5 lines of 'ld --help | less', i.e. you've arrived up to this place:

Code:

      1 Usage: ld [options] file...
      2 Options:
      3  -a KEYWORD                  Shared library control for HP/UX compatibility
      4  -A ARCH, --architecture ARCH
      5                              Set architecture

.

So, just try harder.

I did look through the whole output, I just did not understand a lot of it. The one thing that caught my attention was the --architecture flag, and it just happened to be near the beginning.

tuxdev 04-15-2010 05:19 PM

Quote:

Virtually all Microprocessors but the minority of Microcontrollers; so, did you mean Virtually all by numbers shipped, virtually all by value shipped, or virtually all by availability of type numbers? (Or you could change the word to microprocessors from CPUs.)
Pretty much all of the above. There do exist still some embedded CPUs that don't have an MMU, but it's vanishingly rare.

MTK358 04-15-2010 07:14 PM

Quote:

Originally Posted by ForzaItalia2006 (Post 3936930)
I would recommend the ultimate guide :-) the Intel IA-32 / Intel 64 documentation at http://www.intel.com/products/processor/manuals/-

But that consists of a few 800-page volumes!!!!! :eek:

Sergei Steshenko 04-15-2010 07:20 PM

Quote:

Originally Posted by MTK358 (Post 3937047)
But that consists of a few 800-page volumes!!!!! :eek:

PCI Express standard, for example, is about 700 pages.

What other excuses will you be looking for to avoid reading/learning ? Does yahoo.com work for you as search engine ?


All times are GMT -5. The time now is 03:04 AM.