Slashdot Log In
How OS X Executes Applications
Posted by
Hemos
on Mon Mar 27, 2006 12:04 PM
from the learning-more-about-it dept.
from the learning-more-about-it dept.
MacHore writes "0xFE has an excellent tutorial on Mach-O, which is the file format used by OS X executable files and libraries. It goes into great detail about how Mach-O works, and explains what OS X actually does when it loads and runs an application. Subtopics include Universal Binaries, The Dynamic Linker, Using otool, and other goodies."
This discussion has been archived.
No new comments can be posted.
The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
How I execute applications :) (Score:5, Funny)
How it launches? (Score:3, Funny)
Universal Binaries, The Dynamic Linker, Using otool? pah!
Mach-O (Score:1, Funny)
"Using otool" (Score:5, Funny)
Kinda OT.. yet relevant to this thread (Score:1, Offtopic)
There is one thing without which no Joe User will go, no matter how pretty or compatible linux becomes: installing Apps.
No matter if you are a Windws, Linux or other die-hard you have to admit Mac OS X Make's it damn easy to instll 99% of the apps. Drag and drop what looks like a single file (in reality a *.app folder) and clik to run.
I immediately knew this was huge when OS X came out and made this possible on *NIX machines, and was secretly hoping that Linux wold catch up with it's own version and take-off.
Unfortunately, we are still relying on the age-old install with dependencies, of-course Synaptic, apt and Yum all make that easier but still too complex for 80% of the people.
When will we get drag and drop app install for Linux?
Re:Kinda OT.. yet relevant to this thread (Score:5, Insightful)
We're talking about applications here. On Mac OS X, a properly packaged application lives in a
Any application packaging that assumes that users will not relocate an application is broken on Mac OS X. This means that any having dependencies not contained inside the
Now, some misguided *nix hackers will cobble together an application to run on Mac OS X that scatters little *nix file turds all over various directories, or will hard code installation directories so the application is not relocatable. These are both wrong on Mac OS X (though common practice on *nix) because Mac users have been relocating applications since the mid 1980s, and will continue to do so.
Re:Kinda OT.. yet relevant to this thread (Score:5, Informative)
(Last Journal: Friday February 21 2003, @08:57PM)
No, the post you were responding to phrased it poorly.
What is inherent in a MacOS X version (say, 10.4.5) already covers most of what an application might need, including Apple's "equivalent" of gtk. Go browse the Apple Developer docs sometime, and you'll see a much richer set of libraries that come with the OS by default. Thus, if an application wants an "obscure" library and decides to bundle it, the cost to the system is minimal even if another app has the same one. The MacOS bundle is not at all the equivalent of statically linking against gtk and other "fundamental" libraries in Linux.
On the Mac you have scour the web deciding Free or Paid, [...] Once you've downloaded it, things are pretty sweet, but finding the download can be a PITA.
Have you ever heard of versiontracker?
On the linux box (I am going to choose Debian as I'm familiar with it). Fire up synaptic from the gnome menu. Search for barcode. Two results returned. Both of these programs I know to be free of trojans, compatable with my system & configured for it. To install, I double click.
Which can bring in new versions of a library, which in turn brings in new versions of another application, which may be broken in some way (like any app can be). In other words, installing one app in Linux can effectively break another one. You pay for the isolation available to MacOS X apps in the form of disk space and RAM, both of which can be relatively cheap depending on what you're doing with your computer.
Re:Kinda OT.. yet relevant to this thread (Score:5, Insightful)
I don't believe you!
Yeah, let's talk about bloat... (Score:4, Insightful)
Seriously, how many copies of a library does that leave you having installed?
Generally? One.
Remember, this isn't a Linux distro, where the user has all the choices in the world except the one that matters most: the choice to have all of their apps look and behave in a consistent manner. 99.99999% of all apps targeting OS X link against the standard system Carbon or Cocoa frameworks. The odd app might have a really large third party library linked in and included in the app bundle, but that tends to be the exception rather than the rule, as the bundled libraries tend to be of the small, utility type that only run a few K. How bloated is it? Not very at all.
Now compare that with the situation on your average Linux distro: Instead of one version of one or two frameworks, every third app is written against a different toolkit. Want GIMP? Install GTK. KDevelop? Need QT too. Your text editor links against the athena toolkit, your system management utilities against Tk, your games against SDL, your audio editor against WxWidgets, your file manager against GNOME, something else against FLTK, FOX, Lesstif, Xaw...your shared libraries folder reads like an explosion at the acronym factory. Repeat ad naseum for your XML parsing libraries, your regex libraries, your sound libraries, etc, etc.
And it doesn't end there. Binary compatibility between library releases is the exception rather than the rule. Every third GTK app requires that a different point revision of the GTK libraries be installed. XMMS requires that you install libraries that are several major revisions out of date. You've got 6 different versions of three different XML parsing libraries installed, 2 regex engines, 3 copies of your JPEG, PNG, etc libraries, 3 or 4 different audio libraries with a couple different versions installed. Multiple versions of multiple libraries; an endless proliferation of crap that all does the same job with only the most miniscule of differences. All for the sake of an illusion of "choice" foisted on the end user by a fractious developer base with a raging case of Not Invented Here Syndrome and a belief that their convenience is more important than a consistent experience for the end user.
Now, how bloated must that be?
Ooh, I know this one! (Score:5, Funny)
"0xFE - 1111110b - 0376" (Score:2, Insightful)
iVillage People (Score:1, Funny)
(http://www.arctechnologygroup.com/)
I want to be a mach-o man!
Decent article (Score:3, Interesting)
(http://www.spamgourmet.com/)
I'm fairly new to OS X, and don't know much of the internals and I have no clue on developing via Xcode or a lick about Objective-C.
The otool command is new to me. Its handy because I too was getting "No such file or directory" with trying to use ldd. One thing this article does not mention is weather OS X calls mmap() on an executable and/or libraries? It probably does. I believe all modern OSes do this now, but I could be wrong.
If you like otool (Score:2)
are osx binaries cross-architecture? (Score:3, Interesting)
(http://www.6thstreetradio.org/ | Last Journal: Monday July 19 2004, @11:11AM)
I have a friend who just got a new intel mac laptop. There are a lot of programs which won't run correctly because they don't fully support the intel architecture. However, I know from my linux experience that if I compile something for ppc, and then something for x86, neither executable will even LOAD on the other architecture, let alone execute with any functionality. When I download things for this new mac, I never select anything that is intel specific, and programs like oggdrop and vlc seem to work just fine.
Is this some magic that the program is doing? Or is it on the system level? Or am I missing something obvious about macs?
Re:are osx binaries cross-architecture? (Score:5, Informative)
(http://www.geoffreyspear.com/)
The architecture does support Universal Binaries, which have code for both PPC and intel processors. This isn't really anything new or magical, the OS is just smart enough to know which code to execute. The same thing existed in the classic MacOS to support both PPC and 680x0 systems with FAT binaries.
As with the classic MacOS, there's also an emulator involved, so the newer architecture can run (most) binaries compiled on the older architecture.
However, compile something just for the Intel processors, and it won't run on your PPC hardware. If I understand your question correctly, if things worked the way you were assuming, Mach-O itself would guarantee any Mach-O binary would run on either system.
Since OS X is UNIX based... (Score:1)
Re:boo! (Score:2)
(Last Journal: Wednesday May 16 2007, @12:43PM)
I think thats what Ubuntu is.. or kubuntu or edubuntu or something like that.
Re:I don't have a Mac (Score:1)
(http://www.codemonkeyx.org/)
Re:Obligitory... (Score:2, Informative)
(http://www.foobarsoft.com/)
That said, I seem to remember (and personal experience seems to bear this out) that OS X is really slow executing a fork() system call relative to Linux. I'm not sure if this is has to do with using a microkernel, or is because of specific decisions they made, but anything that fork()s a lot will run slower than on the same computer running Linux.
My only suggestion to you would be... are you running the Dashboard? As interesting as it is, I avoid it because it is a resource HOG like nothing else on the system. If you google around you can even find a way to completely disable it.
In general it is a very responsive system. The only time I can consistently cause a beachball is copying files (digital pictures) off of a CF card. This uses enough kernel time that the computer does seem to stop responding for tiny fractions of a second (and my CPU usage goes WAY up). I don't know what the computer is doing, but it has got to be able to do it faster. My theory? Hard coded uninterruptible sleep statements for timing purposes. Just a random guess though.
All that said, I regularly use a 2.3 GHz Windows laptop and I am constantly amazed at how long it seems to take some applications to launch, and how different it is. IE will come up almost instantly most times. But sometimes it takes 30 seconds to launch and show the page (then feels slow after that). Other apps can do the same thing sometimes. But most applications (IE is preloaded by the OS) take just as long as on my Mac, if not longer.
Re:Obligitory... (Score:2)
(http://mp3bat.com/)
It's you and anyone else who has a 800Mhz PPC. (I've got a flowerpod iMac myself and it is a dog)
If I you happen to have a Intel or a 2ghz G5 then its not as much as a problem.
Even my PPC 1.5Ghz mini isn't as bad as the earlier systems.
Re:Obligitory... (Score:2)
Re:Obligitory... (Score:2)
"that it does in the background isn't helping me check my email, instant message or ssh to remote boxes."
Call me crazy, but I dont think everything linux does is helping you do those things either:
[4294669.546000] Checking for popad bug... OK.
POPAD BUG? WTF THAT IS NOT EMAIL/BROWSING/IM/SSH!!!! STOP WASTING MY MEGAHURTSZ!!!
Re:0xFE (Score:3, Insightful)
(http://weill.org/ | Last Journal: Saturday October 01 2005, @01:18PM)
Re:0xFE (Score:4, Funny)
Re:I don't have a Mac (Score:5, Funny)
(http://www.haeleth.net/)
My question to Slashdot, therefore, is what operating system should I choose?
I've heard good things about FreeBSD's jails, which are apparently very secure without being inhumane. But on the other hand, Windows also has some advantages - I understand it opposes the death penalty so strongly that that it's been known to commit suicide in protest when a user attempts to execute too many applications?
Re:Obligitory... (Score:1)
To put stuff in perspective... it does feel comparable to my old PIII/500 box with KDE & debian.
But hey, ymmv.
Re:Obligitory... (Score:2)
(http://www.foobarsoft.com/)
But for him, I'm guessing his iBook doesn't have a good enough graphics chip, so his CPU is doing all that compositing... which would really slow things down during an app launch.
Interesting point!
Re:What this means (Score:5, Funny)
(http://www.gwtp.net/)
And wormii! Don't forget wormii.
Re:What this means (Score:5, Insightful)
Re:Obligitory... (Score:2, Insightful)
Got a client's 2.1GHz Macbook Pro here and it's really quick to launch everything - Aperture just opens in one bounce and Safari is close to instant. The relative 'slowness' of mach will become irrelevant in the future for sure.
Re:0xFE (Score:2)
According to RFC 1034:
Please read what is written a few lines above: "The following syntax will result in fewer problems with many applications that use domain names (e.g., mail, TELNET)."
I have some code to fix if "someone@0xfe.blogspot.com" could be a valid address...
Time to fix some code then ;-)
Re:0xFE (Score:2, Informative)
(http://machinae.lionsanctuary.net/)
Actually, the full grammar in the RFC is
So a hostname beginning with a digit is actually invalid by the RFC. Nobody actually uses that definition; it turns out it's fairly easy to distinguish a DNS name 127.0.0.com from an IP string 127.0.0.1 in other ways.
Re:Obligitory... (Score:2)
(http://obsessivemathsfreak.org/ | Last Journal: Friday June 09 2006, @08:15PM)
Re:Obligitory... (Score:2)
-matthew
Re:Obligitory... (Score:5, Interesting)
(http://www.last.fm/user/schmod)
This is why BeOS appeared to be lightning fast on even slow machines. Even the smallest tasks were executed independently, and bottlenecks were hardly noticiable.
Apple's doing a good job making everything work, and Cocoa is definitely a step in the right direction, but apple really needs to kill all of the single-threaded applications they've got now. The Finder is the most prolific and outrageous example of this, and anybody who's ever lost a network connection while a network share was mounted knows what I'm talking about (the system virtually hangs for 45 seconds until the connection times out. awful. simply awful)
Otherwise, I love OSX.
Re:Obligitory... (Score:4, Interesting)
Hopefully you won't need to wait too much longer. As reported on Mac Rumors [macrumors.com], as of at least Jan. 26, Apple has been seeking a "Finder Software Engineer". Hopefully we can see a better Finder out in Leopard.
The job requirements were listed as
It is documented (Score:2)
(http://jonscocoa.blogspot.com/ | Last Journal: Wednesday April 13 2005, @06:12PM)
Mac OS X ABI Mach-O File Format Reference
Executing Mach-O Files
Overview of Dynamic Libraries
Re:How OSX Executes Applications... (Score:2)
(http://homepage.mac....mato/Wheatpaste.html)
Re:Interesting, but why? (Score:5, Informative)
(http://port80ware.com/)
Re:Interesting, but why? (Score:2)
(http://atrn.org/)
Certainly. That's why there are documents such as this one [apple.com].
Re:0xFE (Score:2, Interesting)
In old-school records management, 3Com is filed under "T", and 3M is filed under "M" (The name of the company is "Minnesota Mining and Minerals".
Re:Interesting, but why? (Score:2)
Re:Obligitory... (Score:2)
Camino launches in 4 bounces (13 the first time after a reboot). Neither takes more than a couple of seconds.
It might be worth giving your Mac a good old house clean (delete caches, repair permissions, check the disks - all the usual stuff).
And no, your comment isn't flamebait, as far as I can see.
Re:Obligitory... (Score:2)
My laptop is hardly better than the system of the paent's author, but there are only two apps I experience unacceptable launch-waits for: one is a java game platform that the loads dozens more jar files, and the other is Adobe Acrobat Pro, which does something similar.
Actually, in both cases, the app starts and shows itself on the screen promptly, it just isn't ready to do anything for me for a great many seconds.
This is at 1GHz, 1GB, PPC ... and with the Dashboard running. But I must say, I have seen reduced VM trashing with java apps if I first send the Dashboard away by using Activity Monitor to quit (not force quit) the Dock. The Dock restarts right away, but the Dashboard widgets don't start until the next time I visit the Dashboard.
Re:I don't have a Mac (Score:1)