LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 04-13-2010, 08:00 PM   #1
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Protected mode


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

Do you know of any good explanations?
 
Old 04-13-2010, 08:07 PM   #2
MrCode
Member
 
Registered: Aug 2009
Location: Oregon, USA
Distribution: Arch
Posts: 864
Blog Entries: 31

Rep: Reputation: 148Reputation: 148
This section of an "introduction to operating systems" guide has some info on segmentation/sharing and paging. IMO that guide is a fascinating read.
 
Old 04-14-2010, 09:42 AM   #3
paulsm4
Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
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

Last edited by paulsm4; 04-14-2010 at 09:48 AM.
 
Old 04-14-2010, 09:52 AM   #4
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by paulsm4 View Post
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 ?
 
Old 04-14-2010, 10:00 AM   #5
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
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.
 
Old 04-14-2010, 04:04 PM   #6
salasi
Senior Member
 
Registered: Jul 2007
Location: Directly above centre of the earth, UK
Distribution: SuSE, plus some hopping
Posts: 3,902

Rep: Reputation: 775Reputation: 775Reputation: 775Reputation: 775Reputation: 775Reputation: 775Reputation: 775
Quote:
Originally Posted by paulsm4 View Post
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.
 
Old 04-15-2010, 03:57 PM   #7
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
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?
 
Old 04-15-2010, 04:13 PM   #8
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by MTK358 View Post
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.
 
Old 04-15-2010, 04:15 PM   #9
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by Sergei Steshenko View Post
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.
 
Old 04-15-2010, 04:23 PM   #10
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by MTK358 View Post
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.
 
Old 04-15-2010, 04:27 PM   #11
ForzaItalia2006
Member
 
Registered: Dec 2009
Location: Walldorf, Germany
Distribution: (X)Ubuntu, Arch, Gentoo
Posts: 205

Rep: Reputation: 67
Quote:
Originally Posted by MTK358 View Post
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 -
 
Old 04-15-2010, 04:47 PM   #12
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by Sergei Steshenko View Post
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.
 
Old 04-15-2010, 05:19 PM   #13
tuxdev
Senior Member
 
Registered: Jul 2005
Distribution: Slackware
Posts: 2,012

Rep: Reputation: 111Reputation: 111
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.
 
Old 04-15-2010, 07:14 PM   #14
MTK358
LQ 5k Club
 
Registered: Sep 2009
Posts: 6,443
Blog Entries: 3

Original Poster
Rep: Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713Reputation: 713
Quote:
Originally Posted by ForzaItalia2006 View Post
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!!!!!
 
Old 04-15-2010, 07:20 PM   #15
Sergei Steshenko
Senior Member
 
Registered: May 2005
Posts: 4,481

Rep: Reputation: 453Reputation: 453Reputation: 453Reputation: 453Reputation: 453
Quote:
Originally Posted by MTK358 View Post
But that consists of a few 800-page volumes!!!!!
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 ?

Last edited by Sergei Steshenko; 04-16-2010 at 04:52 AM.
 
  


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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Need to write a file in delete protected mode shiv.singh Linux - Newbie 7 05-17-2009 12:59 AM
How to implement memory mapping between protected mode and real mode? me_too Linux - Newbie 0 05-13-2008 01:12 AM
Error in switching from protected mode to real mode in Fedora East Linux - General 0 04-02-2008 02:03 AM
How to patch 0x1c interrupt handler in protected mode john_crichton Programming 2 04-05-2007 04:59 AM
Help with switching to protected mode GDT AT&T assembly!!!! aXoneX Linux - General 0 07-15-2004 09:36 PM


All times are GMT -5. The time now is 01:45 AM.

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 Google+: linuxquestions
Open Source Consulting | Domain Registration