Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Why does Linux run well on so many different types of machines - desktops, laptops, servers, embedded devices, mobile phones, etc? Is it mainly because the system is open, so any part of it can be modified to work in different environments? Or are there other properties of the Linux kernel and/or system that make it easier for this OS to work on such a wide range of platforms?

share|improve this question
6  
I think you have part of the answer already - openness makes it easy for different groups of people or businesses to adapt it to their needs. Since the kernel was notably criticised for being monolithic I'm not sure it's initial design was deliberatly optimised for scalability in any way. I would guess that a greater number of people have worked on the core of Linux than on other operating systems - and perhaps this has forced the core maintainers to take care in dividing the code into pieces with clear interfaces? On the other hand some variants of BSD have portability as an explicit goal. –  RedGrittyBrick Feb 17 '11 at 23:50
    
@Red: It was criticized for being a monolithic kernel instead of a micro kernel -- that's got nothing to do with it's design though. It has to do with how much of the kernel runs in userspace and how much runs in kernelspace. Windows NT's kernel (for example) is very modular, but it is still technically monolithic because most services (i.e. the filesystem) run in kernel mode rather than user mode. –  Billy ONeal Feb 18 '11 at 16:23
    
@Billy: thanks for the correction. –  RedGrittyBrick Feb 18 '11 at 16:55
    
@Billy: Windows NT is technically a hybrid kernel. I believe Microsoft still maintains the subsystems using message passing and keeps the ability to move pieces into user-space as desired. They did this with the graphics system in Vista: it's now in user-space after having been kernel-space since NT 4.0 –  Zan Lynx Feb 18 '11 at 21:21
2  
@Zan: I was under the impression that the status as a "hybrid kernel" was disputed. Therefore I said "monolithic". NT certainly has a lot of monolithic features even if it's split into library-esque pieces. –  Billy ONeal Feb 18 '11 at 22:08

4 Answers 4

up vote 26 down vote accepted

While openness is certainly part of it, I think the key factor is Linus Torvald's continued insistence that all of the work, from big to small, has a place in the mainline Linux kernel, as long as it's well done. If he'd decided at some point to draw a line and say "okay, for that fancy super-computer hardware, we need a fork", then completely separate high-end and small-system variants might have developed. As it is, instead people have done the harder work of making it all play together relatively well.

And, kludges which enable one side of things at the detriment of the other aren't, generally, allowed in — again, forcing people to solve problems in a harder but more correct way, which turns out to usually be easier to go forward from once whatever required the kludge becomes a historical footnote.

From an interview several years ago:

Q: Linux is a versatile system. It supplies PC, huge servers, mobiles and ten or so of other devices. From your privileged position, which sector will be the one where Linux will express the highest potential?

A: I think the real power of Linux is exactly that it is not about one niche. Everybody gets to play along, and different people and different companies have totally different motivations and beliefs in what is important for them. So I’m not even interested in any one particular sector.

share|improve this answer
15  
And the small system and huge system definitions keep shifting all the time, so it's good kludges have been avoided. The multicore smart phones can now benefit from all the super-computer work done years ago. –  Zan Lynx Feb 18 '11 at 21:28

The Linux Kernel scales well because that is what it is. The core kernel is relatively small and does what it need to do. Device drivers are optional and can be left out of the kernel for smaller systems. The beyond the minimal kernel requirements most functionality is implemented as optional features.

Take a look at the config file installed next to most kernels. It will list all the features which were turned on as well as which drivers are supported.

Drivers are supported either embedded in the kernel or as loadable modules. This allows a kernel to be dynamically configured to the hardware it is running on. This is the the approach used by many distributions.

Other than having the compilation tools, modifying the kernel for new hardware is relatively simple. For a new processor only the related code needs to be implemented as modifications to the existing functionality. New devices only require a new driver with the relevant hooks. New file systems are likewise relatively trivial modifications.

The code base has been well maintained to keep this flexibility without external forking. Conditional compilation drives a very flexible kernel which has been kept as minimal as possible.

share|improve this answer

Linux scales to many different types of hardware because:

  • it's very configurable
  • the source is freely available, and can be built for any CPU that has a C compiler available
  • processors in embedded devices and mobile phones have at least the same level or more power compared to the original 386 machines early Linux development was carried out on, and continue to gain power
  • it works just fine with nothing but a network, some form of disk or disk-like device, and a serial port
share|improve this answer
    
Well, someone would need to write a minimal amount of bootstrap code and C runtime for the target platform. Oh, and it has to support virtual memory. But otherwise true :) –  Billy ONeal Feb 18 '11 at 16:20
1  
@Billy There are ports to nommu systems: uClinux, uClinux/ARM, and MontaVista Linux. –  Tobu Feb 28 '11 at 19:08
    
@Tobu: Hmm.. I don't understand how that can be. The entire "Unix Philosophy" for multiple processes has the assumption that something like fork is possible, and fork cannot be done reasonably efficiently on a non virtual memory system. While the indicated ports probably use parts of the Linux kernel and can run some Linux software, for the most part it appears the APIs exposed by these ports are different than typical Linux kernels. (Example: memory mapping -- which obviously requires virtual memory) –  Billy ONeal Feb 28 '11 at 19:56
    
linuxjournal.com/article/7814: says uCLinux does not support fork(), but a blocking variant called vfork(), applications under uCLinux have to be rewritten to use vfork or threads. –  ultrasawblade Mar 2 '11 at 23:36

I lack the detailed technical expertise to back up this answer, but my experience suggests that Linux scales well in comparison to other operating systems that I frequently use (primarily, Windows). So perhaps the question is why Windows does not scale as well as Linux.

If restating the question that way is still useful to you, I would suggest that market forces motivate Microsoft to add features and functionality geared to the latest and most capable hardware, because they sell more copies of the operating system primarily when end users buy new systems. So, at any point in time, I find that the latest release of Windows performs poorly on older, less capable hardware.

Forgive me if that oversimplifies your question.

share|improve this answer
    
It seems you are talking the OS, while the guy is talking about the kernel. Well, unless you know for sure if Windows kernel is bloated. –  Tshepang Feb 18 '11 at 8:58
    
@Tshepang: To be fair, the questions asks about the "Linux kernel and/or system". Do Windows 7 and Windows Phone 7 share a kernel? The little I've read suggests their kernels might have less code in common than the kernels of Ubuntu Server and Android. –  RedGrittyBrick Feb 18 '11 at 17:05
    
Thanks, but the question was really about Linux and not any other OS. There are many others out there: en.wikipedia.org/wiki/List_of_operating_systems –  Justin Ethier Feb 18 '11 at 20:37
    
The NT kernel is actually very efficient, but it's the vast number of layers surrounding it that make –  ultrasawblade Feb 19 '11 at 0:58

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.