Skip to content

Instantly share code, notes, and snippets.

@duckinator
Created November 13, 2009 21:16
Show Gist options
  • Save duckinator/234168 to your computer and use it in GitHub Desktop.
Save duckinator/234168 to your computer and use it in GitHub Desktop.
<duckinator> Is there any reason OSes tend to map the kernel at >3GB in memory?
<geist> duckinator: are you asking why do they map it up high, or specifically why 3gb?
<duckinator> geist: whichever is easier to answer
<geist> or why do they map the kernel at all?
<geist> a bunch of seperate questions, actually
<duckinator> why it's high - why not have it low and put everything else above it?
<geist> you can do that too. BeOS did
<duckinator> so it's just an odd little tradition?
<geist> some architectures require it
<geist> some dont require any mapping of the kernel at all
<duckinator> ah
<geist> x86 sits in the middle. you need some sort of stub always mapped or you take a huge performance hit (TLB swap on every interrupt)
* janemba has quit (Read error: 60 (Operation timed out))
<geist> and traditionally you put the kernel up high so user space code gets to run at 0
<geist> which seems more natural to the vast majority of the code in the system (user space)
<geist> but, for example, OSX on ppc doesn't map the kernel at all
<duckinator> so you just make a special case and have the kernel mapped high, so there's less special cases later on?
<geist> each user space gets the full 4GB, and the kernel lives in it's own 4GB
<geist> sicne there's no penalty at all for swapping the kernel
<geist> actually they do that for x86 as well, and take a performance hit
<geist> OSX only maps a little stub at the very top of virtual space, like 16MB, and use that to switch into kernel space
<geist> duckinator: anwyay, right. yes you put it up high to keep the number of special cases down
<geist> essentially the kernel is a special case versus the rest of the os code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment