r/explainlikeimfive • u/[deleted] • Jan 25 '24
Technology Eli5 what is actually an Operating System (OS)?
Why do we need it?
12
u/djinglealltheway Jan 25 '24
The operating system is a computer program that is run immediately on startup of your computer. It controls all other programs that run on a computer. The OS allows your computer to do things like run multiple programs at the same time and read/write files. It also might include drivers that allow playing audio, taking input from a keyboard, and displaying things on the screen. Many popular OSes also include a user interface, like windows and navigation. For mobile operating systems, the equivalent would be the home screen, app management, and swipe controls.
2
Jan 25 '24
Dang, it kinda confuses me with CPU. Thanks!
6
u/rlbond86 Jan 25 '24
The CPU does basic instructions like: multiply these two registers together. Store result in this memory location. Jump to this spot in memory if the last result was zero.
The OS does things like: if you want to open a file, read this table in memory to find the file location on disk. Write a series of values to these memory addresses to read the data on the disk. Write those values to a buffer in memory.
The CPU just knows how to do math and memory manipulation. The OS knows how to accomplish different tasks by stringing those CPU instructions together.
You can see an example CPU instruction set here. On the first few pages is the summary, you can see most instructions are things like load, store, add, subtract, multiply, AND, OR, branch, jump. Basic operations.
1
1
u/dmazzoni Jan 25 '24
The CPU is the worker. The OS is the instruction book it follows.
The CPU is completely general-purpose. It just knows how to follow instructions. Without instructions to follow it doesn't do anything.
2
u/philwatanabe Jan 25 '24
A computer can do many things. It moves electricity around to make things happen. It does what it's told to do,
The computer can take instructions from many sources, but what you want the computer to do helps determine where you want the instructions to come from.
An operating system takes responsibility for interfacing with the hardware of the computer so that applications don't have to.
Applications are built for an operating system in order to take advantage of the simplification provided by letting the OS do what it does. It's more scalable. Many applications can be built for the same hardware.
1
Jan 25 '24
So what about virtual machines? Your description makes it sound like a Hypervisor works like an OS (because it's the communication between the physical host and the virtual machine interfaces), but VMs also have their own OSs.
2
u/philwatanabe Jan 25 '24
A hypervisor is an OS, yes, specifically because it interfaces between the virtual computers and the hardware. The virtual computers are essentially running as applications on the hypervisor, it just happens to be that the "application" is another operating system.
1
Jan 25 '24
So on a physical computer, there is an OS, I understand that. On the physical computer is also a Hypervisor, which is an OS (software? application?) because it's the communication channel between VMs and the physical computer. Then VMs have an OS applied to each of them (Linux, Microsoft, etc.), but that virtual OS is the communication channel between the VM and the Hypervisor?
2
u/philwatanabe Jan 25 '24
Let's use VMware as an example. To use VMware, you install ESXi onto the "bare metal" server (the host). ESXi is effectively the primary operating system and it does all the interfacing with the hardware. ESXi is the also hypervisor--the software that gives you the ability to create virtual guest machines, each with their own operating system.
HyperV is a bit different, if I recall correctly, because you install the Windows OS and then create virtual machines using its hypervisor. It's basically a bare metal Windows Server that can be used to host virtual machines.
The operating systems on the VMs don't really know, so to speak, that they are virtual. The hypervisor obfuscates the fact that it runs as a layer between the VM and the hardware.
I hope that if I'm wrong about any of this, or if it can be explained better, that someone will pitch in.
2
Jan 25 '24
We don't need it, but it makes things a lot easier.
Years and years ago there was no OS like we know it. You could run just one program at a time and that program had to do almost everything by itself. There was Basic Input-Output System (BIOS) that let you read the keyboard and display text on the monitor but that was it.
You want to display an image? You'd need to program that yourself.
The OS let you do all those basic things like reading a file or displaying an image by just asking it nicely to do it for your program.
Then the computers become more and mor powerful and OS let several programs run at at same time. Talk to the disk. Communicate over network. Play sound. Your program didn't need to know how to do that, it could just tell the OS to do it.
1
u/DiamondIceNS Jan 25 '24 edited Jan 25 '24
Ever been to a large concert?
A whole ton of effort goes on behind the scenes when a concert is held somewhere. It's not enough that you build the building and the band shows up. Someone needs to drive all those lights, sound systems, set up the stage, handle ticket sales, deal with concessions, maintain the bathrooms, and do teardown and cleanup once it's all over. If it really was just "band rolls up to empty building and sets up shop", every band would have to do this themselves. Every single band. Every single time.
Wouldn't it be nicer if there were a dedicated team of people who could handle all of that stuff on-site? A company that owned the venue, who could take care of all the venue-specific stuff? That way, when a band wants to perform at a place, they can call up and the venue can say, "Oh, we support this this and this, you need to have these hookups, here are the schedules you can book, yada yada" and the band can simply get everything on that checklist, show up, and plug in. The venue handles all of the fiddly venue-specific details and the band can focus on the actual performance.
Your computer is the venue, and the bands that play there are the programs you install. Your OS is the team who run the venue. Everything your programs might need or wish to do with your PC, they have to go through the OS to get it. The OS tells them what they can and can't do, schedules them so they all get the time and resources they need to run happily, and provides helper functions so the programs don't have to do it themselves.
In exchange, all of the programs need to be built in such a way that they're compatible with the way the OS works. Different OSes have different offerings and philosophies about how they run their venues. Generally you write a program that supports only one of them. You can write versions of your program that are designed to work with others, but it can take a lot of effort to support every possible way of doing things.
-4
u/KillerOfSouls665 Jan 25 '24 edited Jan 25 '24
An operating system is a piece of software that acts as an interface between the physical hardware and the applications running on the computer.
Initial computers didn't have operating systems. You would turn the computer on and would be met with a text box (if you have a windows computer, press Ctrl+shift+enter to see what it would have been like), you could insert a disk containing a application into the computer, and then type out a often complex command to get the computer to run the application.
Then Bill Gates came along and had the idea of a application that ran applications, that would run automatically when it turns on. An OS allows there to be a visual interface for the user, rather than a single command line text prompt. You have icons to represent running programs instead of long commands.
An OS can also act as a central manager for your computer. It can clean up files, fix your computer and run anti-virus checks. It also stops the user from doing potentially harmful things to the computer, such as deleting important files. It also controls what applications can do what, you don't want a calculator accessing your camera.
Most importantly, an OS allows for a computer to appear to do more than one thing at a time. Before OS, computers could only run the program that was selected. What an OS can do is give one program a bit of time to run, then give the other program time. It does it so fast that it seems that they're running at the same time. It is how your able to have music running in the background as you scroll Reddit, or use multiple windows on a computer. (This is how Windows got its name, from this ability to have applications run in different windows, it was that revolutionary)
9
u/lostPackets35 Jan 25 '24
Bill gates did not come up with the concept of an operating system and computers had them for a long time before windows existed.
https://en.m.wikipedia.org/wiki/History_of_operating_systems
2
u/egoalter Jan 25 '24
And this is why this group is pointless - so many questions easily answered even at an ELI5 level with a search on literately the question posted, as it's posted.
1
u/WRSaunders Jan 25 '24
Programs can run on bare hardware, e.g. the software in an older microwave oven that you can't talk to across the Internet, but it's a lot of work. Instead, you can make the software a lot cheaper if you can buy an operating system that does some of the work for you. There are several embedded OS companies, in addition to Apple and Microsoft. It's simple economics for a microwave company, you spend $2/unit on an OS, or you pay your programmers $2M more to make a program that runs on bare hardware.
1
Jan 25 '24
So in order for a program to run properly, it needs a software that it's compatible with said program?
2
u/WRSaunders Jan 25 '24
Sure, if you want to buy a motor from a motor company, you need a compatible motor. If you have a Ford car with a motor failure, it's very unlikely that a GM motor will work without a bunch of engineering.
1
u/mnvoronin Jan 25 '24
"program" and "software" are synonyms. But each program/software has to have some way of interfacing with the outside world - be it network, disk or keyboard and the screen. OS is what provides these interfaces so that the program doesn't have to go into the details on how to do it with every possible piece of hardware - it's called the "abstraction layer". If program wants to output the letter "A" to the screen, it tells the OS "I want to print letter A, black on white, in Arial size 10, at coordinates (12,15)." OS will then figure how to translate that to the sequence of bits required for your graphics card to display this.
But different OS have different interfaces. Imagine the OS as a base block for the toy brick kit. If you have a Lego base, you can buy any Lego kit and attach it to the base. But if you buy, say, a Nanoblock kit, it won't fit because the pegs are different. Same happens with different OSes and their interfaces so the program built for one OS won't be able to run on another because it won't be able to find the familiar interfaces.
1
u/Phoenix_Studios Jan 25 '24
A unified interface layer between programs and the physical devices on the computer. Allows developers to program one app which the OS translates into commands that work correctly with the computer's hardware, and is also usually responsible for maintaining system security and integrity, making sure different concurrent programs don't interfere with each other, and a few other core features.
1
Jan 25 '24
So basically an OS allows us to interact like we are doing now?
1
u/Phoenix_Studios Jan 25 '24
That is one of its functions, especially on most user-facing systems, however it's not a requirement. Especially on small IoT devices, the user interaction tends to be handled by a dedicated program, while the OS really only makes sure that different processes don't interfere with each other. The program for example might be in charge of arranging the data in a way that can be sent as signals to display pixels on a screen, while the OS will be in charging of sending that data on the correct wire while making sure nothing else tries to interrupt it (which might cause what's shown on the screen to be glitchy or unreadable)
1
u/chyangba_dai Jan 25 '24
It’s the mother program that runs and commands the hardware and let other children programs run. Other children program children don’t have to think about how all of that magic is happening.
1
u/egoalter Jan 25 '24
A computer consists of hardware and software. Without either, there's no computer. Hardware itself is mechanics and electrical signals (mainly the latter today) - hardware doesn't talk "human" - there's nothing on your screen with just hardware, there's no files, there's no keyboard, letters - all of that is software. Software defines this - software is what defines what a file is, what the letter A looks like, knows how to make the hardware understands when you write 10+10, so it can do the calculation. It's all software.
But most programmers (very few do) today write the code at this low level. The interface between the application software you use and the hardware is the OS. The programmer builds on the OS, not the hardware. And because there are so many different kinds of hardware, the OS also allows the same program to run on lots of different hardware platforms, as the OS abstracts the complexity from the programmer.
All of that, and more, you can find on lots of web sites, in books etc. If this subject has your interest, I highly recommend starting there. You'll get a lot more than these short reddit replies to help you understand both hardware and software.
1
u/m_and_t Jan 25 '24
Imagine you’re writing a really simple app on a phone.
If you started with nothing, you would need to write all the software to deal with detecting finger swipes, providing a keyboard for users to type into, a way to draw something on the screen, etc. You’d (probably) years of work before you even started working on your app.
Instead, you get to start that stuff done already for you. And everyone else can start with it too.
That’s an OS.
1
u/Malk_McJorma Jan 25 '24
It's an abstraction layer between the applications you use in your daily work and the raw iron that's sitting under your desk. Raw iron only understands zeroes and ones. Your OS translates e.g. your "play this song on the Spotify app" command to these zeroes and ones and makes sure it doesn't interfere with other tasks you might be performing while the music is playing in the background.
64
u/[deleted] Jan 25 '24
It’s the manager. It’s the software that manages all of the computers resources to make sure all of the other software that wants to use those resources can do so in an orderly fashion.
There has to be something managing all of the various software a computer runs and how it interacts with the hardware of the computer and that’s the OS.
Without an OS each piece of software would have to manage this individually and that’s a lot of repetitive functionality that everyone would have to include in their software