Understanding OS X Kernel Internals
jglidell writes "The OS X kernel has been in the news alot this past year, whether it's why its slow, Mach/micro-kernel makes it bad, it's going closed source and what not. Amit Singh has put up a new presentation on the innards of OS X. It does a pretty good job of summing up the OS X kernel architecture, and has some pretty detailed diagrams... for instance they show that there are so many process/threads layers in OS X. So if you are in the mood for doing some OS studying then head over."
1. Make presentation and push for own book about subject /.'ed
2. get
3. profit!
Grrr... "alot" isn't a word! It's "a lot."
The spelling police are on their way!
nobody notices how slow your black Macbook is.
whether it's why its slow
What the hell does that mean ? Editors drunk ?
"alot"
"whether it's why its slow"
"they show that there are so many process/threads layers in OS X."
Do the editors even look at submissions any more? Or to put it another way, is our children learning yet?
All the stupid code poems are why it's slow! Apple needs to spend less time acting like Edgar allen Poe, and more time fixing their crappy kernel.
Your karma check for today:
There once was a user that whined
his existing OS was so blind,
he'd do better to pirate
an OS that ran great
but found his hardware declined.
Please don't steal Mac OS!
Really, that's way uncool.
(C) Apple Computer, Inc.
The hissing/squeeling noise on Intel Duos... nice not even windows has that. Their solution: run it with sufficient load that one of the cores doesnt shut off.
Looks to me like the hardware declined Apple.
And wasting their time on lame fat/suit vs hip/cool commercials is another reason why.
Apple is looking to drop the burden of having to support their own niche OS as quickly as possible.
After getting the boot from IBM, Apple is the sole x86 OEM saddled with the tremendous expense of funding the research, development and support of an entire OS all on their own. Intel Mac sales have been no better than previous Macs - and with the massive heat and other problems the new Intel Macs are having sales could get much worse.
Apple will most likely sell of the good bits of OS X to Microsoft fairly soon as OS virtualization is going to kill off the native OS X software market. Reading up on OS X might be of historical interest, but for most people it will be of almost zero practical use soon.
Hemos, do your fucking job!
I have a small program that mmaps a bit of code and then points the program counter at it. Everything runs fun until a OS call happens. I've heard that Mach allows user land programs to install their own OS calls but I haven't seen any example code to do it and I suspect such a feature isn't in OS X. I've hunted through the source and I while I could write my own system call and compile it in, there should be an easier way. Can anyone point me in the correct direction?
could care less about kernel space issues, especially the average Mac user. I know I don't. I work in IT security, and all I care about is that I can lock down the machine. The more common users of Macs just care that their USB devices work and that they can connect to the Internet. Nothing else matters to people unless they are developers or CS students. Slashdot is posting some real boring stories, and this is one of them. I'd rather see a story on OS X security from a user perspective or even OS X widgets than this.
If English is a second language for the submitter, fine. But good grief, do you suppose one of the PAID editors could have done just a bit of work to make the summary more readable?
Before anyone starts spouting off again about Mac OS X being "slow by design" or somesuch, read this article by an Apple engineer that investigates those claims.
A flash presentation which is over 6 MB large (still loading)..
Good bye, dear server!
"Or to put it another way, is our children learning yet?"
Three errors in your statement, only one which seemed intentional (and should have been in quotes).
Other errors you missed in the report include:
"and what not" should have a comma before "and"
"So if you are in the mood for doing some OS studying then head over." should have a comma before "then" and would be less awkward without the word "then."
No soup for you.
I looked at the "presentation" and no, it doesn't do a very good job of explaining anything. Maybe combined with an extensive lecture to explain what the hell he's talking about would make it a bit more clear. From what I saw it was basically just enumerating the different components. Then I noticed the second to last slide. It's basically an ad for a book coming out.
Maybe it's just me though. Did anyone else find it extremely enlightening?
As the purchaser of a brand new Core Duo Mini, (my first Mac, I feel "as happy as a little Gurlll!") I noticed that my system out of the box with 512 of RAM was dog slow when you start loading iPhoto, or any more then 2 apps.
Initial startup yielded a smoking fast web browser, and other single line items.
I purchased the 2GB Ram upgrade (not from Apple at 600 USD, 280USD from Crucial) and I noticed such a difference, that I couldn't understand WHY they would even consider shipping that little silver wonder with less then 1GB of RAM.
It's not the kernel, it's the apps... They just don't give enough power to the off the shelf machines to support the great apps that come with it.
Vive le Mac... Thanks for putting excitement back into computing for me.
Riiiight. Just because some idiot alarmists say that the kernel has gone closed when it simply just hasn't been released yet, the media and clueless bloggers start crying that it's gone closed source.
"Well... it hasn't. It's still open. IT JUST HASN'T BEEN RELEASED YET.
OSNews is reporting that Ernest Prabhakar, Apple's Open Source and Open Standards product manager, has stated in the Fed-Talk mailing that Apple has not actually closed Mac OS X's Darwin kernel for the Intel version of the OS; they simply haven't released it yet. Speculation about Apple closing the kernel arose from the fact that other non-kernel Darwin sources actually have been released, and the previous PowerPC-based kernel is still available as open source as well.Ernest wanted to make sure that tech media didn't confuse 'speculation' with 'fact'. A good lesson we all could benefit from...."
God damn alarmist idiots.
Wowzers....1900 pages uh uh uh uh uh...compllekks! - Jeff Lebowski
Insinct is stronger than Upbringing - Irish Proverb
Werent we told recently that we no longer have the right to make modifications and compile the apple kernel from source?
Maybe it would be useful to look at it for learning purposes, but now-a-days I believe you can get into quite a bit of trouble if you look at source code thats not your own then go off to make your own project under a different licence.
...The 'number of people' that you know can't _really_ be that serious about buying a new computer if some goofy ads caused them to band together, revolt, and refuse to take their medicine...
Get serious guy... Ads stop them from buying a Mac but Vista delays, security holes, and focusing on a game machine don't turn someone off of buying a Windows PC?
If I could mark you as a 'troll' I would but I'm just a lowly 'a. coward' here...
As an ex-NeXT developer, the historical speed bumps behind this architecture are directly related to code density. NeXTSEP ver 2.0 was nicely running on 25mHz. NeXTSTEP ver 3.0 suffered performance on 25mHz compared to ver 2.0 because of the additional kernel overhead resultant from code densification.
With every ver. release through 10.4.x MacOS X, mach/BSD layer exhibits funtional improvements with speed increases of the processor CPU and latent performance behaviors from the additional kernal overhead added by code complexity and densification.
Prima Facia evidence to the 4X speed improvement in performance from Apple's new Intel CPU bears witness to the limits of the kernal architecture.
"The OS X kernel has been in the news alot this past year, whether it's why its slow, Mach/micro-kernel makes it bad, it's going closed source and what not. Amit Singh has put up a new presentation on the innards of OS X.
The OS X kernel has been in the news alot this past year[.] Whether it is why it is slow [(]Mach/micro-kernel makes it bad[)] [OR] it is going closed source and what not[,] Amit Sing has put up a new presentation on the innards of OS X.
The OS X kernel has been in the news alot this past year. Whether it is why it is slow (Mach/micro-kernel makes it bad) or it is going closed source and what not, Amit Sing has put up a new presentation on the innards of OS X.
Ummm, lets see, since its a Mac it would be COMIC SANS! What do the Windows people call it?...
PerforMing.' Even
I know that the original code, from NeXT, was Mach because there wasn't any choice. But in this day and age there are plenty of microkernels that actually perform well, even as a platform for full kernels. There's plenty of benchmarking for Linux on L4, and Linux on Exokernel. Both have minimal impact on performance. (L4 is usually 2-10%, Exokernel is similar.) Mach is a dinosaur. And since microkernels are small, with well-defined interfaces, porting to a more modern one should be relatively easy, even keeping backwards-compatibility of libraries. (You might need a mach emulator, or mach-on-top-of-l4 for a few mach-specific system calls, but that would hardly be a problem.)
So why hasn't apple done it?
"Don't forget that the Intel iMacs don't have dedicated video RAM."
ATI Radeon X1600 Graphics gives iMac the PCI Express treatment on a 16-lane bus interface.
-Apple's Webpage
It may surprise many Slashdotters that there are people in the world who can effectively write both English *AND* PERL. I detect a lack of effort, education, or both.
There's plenty more.
There's no doubt in my mind X is many times slower than it needs to be. Most of it is in the kernel though, not the call site.
http://lkml.org/lkml/2005/8/20/95
My opinion is that mac OSX is very well designed if you beleive that in the future there is be more and more "cores" inside most notebook and desktop computers. OSX is well setup to take advantage of 8-core machines. It should scale well.
Far from enough. You need as much as possible to taste the Adobe Creative Sweet.
There is a spark in every single flame bait point.
Kernel and Kernel Theory Aside...
Most Apple applications themselves tend to be a bit 'bloated'. No matter how fast the kernel is, you have a bit of a bloated GUI construct (especially in terms of RAM Usage) then add on the RAM used by some of the built in applications, and ouch.
And no, not all of Apple application are bloated, safari isn't bad in terms of size and performance in comparison to some of their other creations like iPhoto, etc...
You can almost pick through the applications included on OSX and see where the developers just were rushing to get the product working and the ones that performance and RAM usage were seriously taken into account.
Even iTunes is not built for speed nor does it seem to care about a low RAM footprint.
OSX performance needs to be debated, but in three parts at the very least. The Kernel OS Layer, The GUI Layer, and the included Application level.
Here is what is really sad, Vista in Beta is snappy with 512mb and 512mb is the 'recommended' RAM for optimal performance as well. (Of course that is if it ever ships, but in the meantime, a Beta OS full of debug code should not feel snappier than an OS that has been refined for last 6 years like OSX.
Mac means "pimp" en français. Thought that was rather funny.
So, if X's micro kernel is slower than a monolithic kernel, and current tests show OS-X is as fast as Windows then....
Mac OS-X could be faster than Windows. Yes!!! I love it!!!
Uh, they don't pay attention to Vista. They don't know what OS-X is. They don't need to know. They don't CARE.
They heard that "Apples just work", and they like their iPods. Then they see these commercials who basically say the best reasons to get a Mac are that it has applications for things which they already have applications for, and it doesn't get viruses despite viruses not being a problem for them because they have antiviruses...
So yes. They WERE serious. They aren't now, they're sticking with generic Windows computers.
Apple discourages employees from writing books. It's part of the employment contract that you don't write books about Apples current or prospective business, and an internals book would qualify.
It's supposedly possible to get permission from the lawyers, but in practice, they won't let you put your name on the book, and you have to have a publisher up front, and there are other restrictions that make it impossible / not profitable.
-AC
You are incorrect, sir.
/dev/null and /dev/zero, and then turn any reads or writes from either around immediately in the first function called out of the sysent[] table as soon as you see an fd pointing to one or the other, and never enter into the rest of the kernel. Then you can run the lmbench "system call speed" tests, with everything *but* the call site overhead factored out.
It is a trivial experiment to initially cache the vp for
The real problem here, though, is the perception that system call trap speed is actually somehow very important. This has grown out of the Linux community.
Part of it is Larry McVoy's benchmark suite, designed to make Linux look better than other OSs; the perception that system call speed is important is based on the idea that since it can be measured, making it small as possible is worthwhile. As evidendence that this is actually jingoistic, the previous "null system call" implementation in LMBench was actually getppid(), and prior to that, it was getpid() (the result of getpid() is cacheable in user space in Libc). As other OSs have started turning the calls around faster, other calls have been selected to keep Linux ahead.
The second part of the problem is deeper, and goes to how people program software being influenced by their execution environment, and their perception. This is more problematic. Whether it's the idea that it's OK to not bzero() a sockaddr_in before using it in a call to connect() (which works on Linux, but fails on most BSD derived systems because of the "mutual connect" case in the TCP state machine that isn't accounted for in the Linux implementation), or it's the idea that thread creation or system calls are "free", and therefore not to be avoided, or whether its something else, it ends in bad code.
My canonical example for this is MySQL's client libraries, which end up making multple system calls (3 of them) per transaction, when they could get by with a single system call simply by buffering their data per client connection, rather than per thread in the MySQL server. This simple change would amount to a huge performance improvement on most OSs; Linux itself would see perhaps a 5% performance improvement from the change. But it would be an improvement. Yet people keep pointing to MySQL as a benchmark, when what they are measuring is actually a design problem in the database, not the OS on which it's running.
The problem is that most people don't change code, once they get it to the point that it works well enough for their initial uses - and short of someone doing a deeper port than just a trivial "get it compiling and running" type port, you're not going to see the performance on *any* platform that wasn't the initial platform where the code was written and tuned. Or to put it another way, the person most capable of tuning the code is almost never going to be the person moving it to a new platform; so platform assumptions built into the implementation of the code - or worse, the design of the code - are going to bite everyone that moves it to a new platform.
For thread creation - well, you know, there's a good reason that Apache pre-spwans anonymous workers, and applications that don't are probably assuming that thread or process creation is "free" or close enough that they don't care.
Personally, I'm not that impresed with benchmarks that purport to measure kernel performance; other than I/O, where most of the time is spent waiting on whatever you're talking to, well written applications tend to spend their time in user space; I've heard that on MacOS X, it's usually more than 80% of the time in user space, and for multimedia or compute bound applications, it can get a lot higher than that.
Microbenchmarks have their place; they are useful for comparing against yourself, and for detecting regressions before they become entrenched. But they aren't very useful for anything else, and exspecially not for comparing one OS to another.
-- Terry
No, actually I don't think that's a correct usage of "it's" and "its."
He should have used "it's" in both cases. (Because "it's" is a contraction of "it is," while "its" is the possessive.) If you read it to yourself, replacing the apostrophe with the individual words, it becomes more clear.
For example, "whether it's why its slow..." I think should parse as 'whether it is why it is slow...' (which makes sense, if only as a fragment). So "its" in the article should correctly be "it's."
You can't have "why its", because the word 'why' can't possess anything. (Well, you could potentially have a question -- "Why its?" -- but that doesn't make sense in the context of the summary.) Frankly, the author would have been best served by dumping all the contractions and just running with the extra words: the few extra characters would have been worth not making the reader have to sound out the sentence in order to figure out what was meant.
I'd say the article is typical at 1 out of 3 correct, but still manages to be nonsensical for other reasons.
"Ladies and gentlemen, my killbot features Lotus Notes and a machine gun. It is the finest available."
So is this post about the Crapple Suckintosh?