Why can't Windows run Linux binary executables?

This is a discussion on Why can't Windows run Linux binary executables? within the Tech Board forums, part of the Community Boards category; And then...
Why can't Linux run Windows programs?
Is the kernel the issue here?
Couldn't the kernel coders allow some ...

Why can't Windows run Linux binary executables?

And then...
Why can't Linux run Windows programs?

Is the kernel the issue here?
Couldn't the kernel coders allow some "emulation" of some other OS's system calls so that the executable that runs on that OS runs just as fast on the one with the "emulation"?

The big question I'm asking is:Could Windows add functionality to itself, to run Linux binary executables (ELF) efficiently and natively, if they really wanted to?
Is it possible?

There are two main reasons that binarys from one OS can't be run on another OS. First is the fact that the binarys are in different formats. Linux uses ELF, and Windows uses PE. Now that compatibility can easlily be overcome, but the other problem is the OS library functions that all applications use must be ported over as well. Applications need to use OS system functions to do just about anything at all. This includes printing to the console, opening/closing files, creating windows, etc.

There is a project called WINE which is attempting to port all the windows system libraries over to linux, but it still has a long ways to go before it is complete.

There are two main reasons that binarys from one OS can't be run on another OS. First is the fact that the binarys are in different formats. Linux uses ELF, and Windows uses PE. Now that compatibility can easlily be overcome, but the other problem is the OS library functions that all applications use must be ported over as well. Applications need to use OS system functions to do just about anything at all. This includes printing to the console, opening/closing files, creating windows, etc.

There is a project called WINE which is attempting to port all the windows system libraries over to linux, but it still has a long ways to go before it is complete.

But what if a user on Windows double-clicks an ELF executable, and somehow the kernel can figure out that its ELF, and so it knows when something like this happens... write(1, "sup foo", 8); the kernel could somehow replace the call with a macro that does: windows_version_of_write("sup foo", 8, CONSOLE_OUT); or whatever.

Or Windows could just copy the whole open source linux library and just pipe the executable to use that instead of Window's. Then they could rewrite the Linux library to mingle with its own API innards.

The problem I see with WINE is that it's slow, but if WINE was at the kernel level, then perhaps it could run faster since it would be closer to the machine, or something.

I know it would be hard for someone to create a kernel-like-emulation for Windows on Linux. But a Linux on Windows, think of the power, Windows could become a WinLinux super system! I know there is a program that runs Linux programs on Windows, but if Microsoft could release Windows with Linux kernel capabilities, then Windows would be an unstoppable giant!

Well you're talking about running Linux programs on Windows, and there isn't any need to do any of this fancy emulation stuff for that. 99% of Linux programs are open source, and so they can easily be ported to Windows. In fact, I'm having trouble coming up with any notable Linux user application that doesn't exist on Windows.

But emulators are slow. If Windows wants to run all Linux apps full throttle, then Windows needs to run ELF apps close to itself, built-in to the system, so that the apps run as fast as possible.

Originally Posted by Thantos

The problem is that no matter what you'll need a translator to go from one format to another.

I'm not totally sure what you're saying.

Originally Posted by bithub

Well you're talking about running Linux programs on Windows, and there isn't any need to do any of this fancy emulation stuff for that. 99% of Linux programs are open source, and so they can easily be ported to Windows. In fact, I'm having trouble coming up with any notable Linux user application that doesn't exist on Windows.

What about assembly? I read about people having problems switching between Operating Systems (mainly from Windows MASM -> ?? Linux) ex: http://groups.google.com/group/alt.o...fd93d1e6c6a2dc
I feel that there are problems between OS machine code portage, and that can be solved through kernel binary executable discovery. Wouldn't it be nice on Windows if you could download the same EXEs that Linux people download and run the application at the same speed as people on Linux?

Then Microsoft would conquer because there would be no reason to be on Linux anymore. All of the Linux apps run natively on Microsoft because of something called binary executable discovery that figures out if its an ELF or not.

I believe this is something close to DOS (16-bit) emulation in XP, not sure though.

what he's saying is that no matter how you cut it, you need something to change the basic machine-level code from one OS to the other, wether it's a layer between the binary and OS (an emulator), or a part of the OS itself (it would still be a layer, just not a standalone layer)

basically, this is how it works:
you write: print this to the screen
the compiler writes: since you're on linux, you have to use method L to write it

when you run your program on Linux:
the program says: use method L to write this.

when you run your program through an emulator on windows:
the emulator sees: use method L to write this.
the emulator says to the OS: use method W to write this.

if windows had a built-in emulator (I'm theorizing here):
windows sees: use method L to write this
windows figures out that method L is native to linux (or the user configures windows to assume this for this binary)
windows uses a built-in emulator to translate that to: use method W to write this
windows' built-in emulator passes that further into the kernel.

as you can see, even if that were somehow embedded in the kernel, it would still be there, and it would bulk up the kernel, making it less efficient overall.

the big answer to your big question:
yes, windows could build that in, but microsoft is in the business of building windows. They do not want to build windows+linux+mac+whatever supergod operating system. it's too much work and really not worth it. plus, I can't imagine that really be good for anything anyway... besides, that would take ALOT of money, and processing power, and if you wanted to add mac in the mix you'd need an insanely huge amount of hardware knowhow. it'd be near impossible in fact.

the small answer to your big question:
yes, but how would that benefit microsoft?

the big answer to your big question:
yes, windows could build that in, but microsoft is in the business of building windows. They do not want to build windows+linux+mac+whatever supergod operating system. it's too much work and really not worth it. plus, I can't imagine that really be good for anything anyway... besides, that would take ALOT of money, and processing power, and if you wanted to add mac in the mix you'd need an insanely huge amount of hardware knowhow. it'd be near impossible in fact.

Hmmm...ok you're probably right on that, that Microsoft would have no motive to natively run Linux applications on its Windows operating system.

BUT, I do believe Linux would want to run Windows apps natively.
Now, if I was a super genius, could I convert WINE to allow the kernel to be able to read the Windows executable file format?
^^^The super big question lol

The kernel would become much bigger, but that's a given...

So what would happen, is something like this:

Code:

$: ./flashmx
... the kernel recognizes that this is a windows application
... initiates the windows library filled with window calls wrappers
... the app calls those wrapper functions

Most windows apps don't run in kernel mode they run in user mode even user32.dll which is used to create windows, dialog boxes and other user interface elements is run in user mode.
If you ported a linux app to windows it's going to run faster then if the binary was run thru an emulator.
Another problem is that even program that are designed to be portable loose some efficancy because they don't take advantage of the structure of a particular OS they have to work for all supported OSs. This problem would be even worse in an emulated environment.

Or is it a kernel feature? If the windows execution format is inside of linux as an internel system (much like how Linux handles ELF) (like an exact copy of Windows runtime built into Linux), then I doubt it would be called an 'emulation', and thus wouldn't be slow.

Originally Posted by Quantum1024

Another problem is that even program that are designed to be portable loose some efficancy because they don't take advantage of the structure of a particular OS they have to work for all supported OSs.

And if this system was built by a super genius, then people could create binary executables for Windows, or Linux, and it would all run at the same speed and just as efficiently on Linux...then Linux would have no problem at becoming the best OS.

then of course there's the kernel bulge.

Originally Posted by kermit

What is more realistic is a dual boot setup. Just use one or the other.

True, but I'm thinking of an all-in-one package. People wouldn't need Windows anymore to run [the current windows apps that WINE can run], but rather they could use this super version of Linux that can run it all (most), and run it just as quickly as Windows!