How do operating systems work?

Creating an OS is like a massive project. How would anyone even start?

For example, when I click Ubuntu on my disk, how can my computer start it? (This, I think, is what I really would like to know.)

Or, looking at it from a different angle, what is the smallest number of bytes that can be on a disk and still “run” as an OS?

(I apologize if this is vague. I just have no idea about this subject, so I can’t be very specific. I pretend to know how many computers work, but I don’t know this subject at all.)

+46
operating-system osdev low-level
Dec 31 '09 at 18:43
source share
25 answers

Well, the answer lives in the books: Modern operating systems - Andrey S. Tanenbaum - very good, Illustration below.

The simplest but complete kernel of the operating system, suitable for learning or just curiosity, is Minix . Here you can view the source code .

Modern operating systems http://www.cs.vu.nl/~ast/books/mos2/big_cover.jpg

+35
Dec 31 '09 at 21:17
source share

Operating systems is a huge topic, the best thing I can recommend to you if you want to talk in detail about how operating systems are developed, and compiled her a good book:

Operating system concepts

Operating system concepts

+18
Dec 31 '09 at 18:52
source share

If you are really interested, I would refer you to Linux from Scratch as a good place to find out all the inputs and outputs of the operating system and how all the parts fit together. If this is more information than you are looking for, then this Wikipedia article on operating systems can be a good start.

+12
Dec 31 '09 at 18:50
source share

The PC knows how to search for a specific sector of the disk for startup instructions. These instructions will then tell the processor that specific code should be called at given processor interrupts. For example, with a periodic tick, call the scheduler code. When I get something from the device, call the device driver code.

Now, how does the OS configure everything using the system? Hardware also has an API. They are written with a system programmer.

I saw a lot of bare-bone OS, and this is really an absolute core. There are many built-in embedded OSes that they all do and nothing more.

Additional functions, such as the requirement that applications request the operating system for memory or require special privileges for certain actions or even processes and threads, are indeed additional, although they are implemented on most PC architectures.

+11
Dec 31 '09 at 18:49
source share

An operating system is simply what allows your software to manage hardware. Obviously, some operating systems are more complex than others.

In the very center of the computer, the computer starts up with a fixed address, which means that when the computer starts up, it sets the program counter to a predetermined address and only starts to execute machine code.

On most computers, this “boot-up” process immediately initializes known peripheral devices (such as a disk). After initialization, the boot process will use some predefined sequence to use these peripherals. By repeating the disk driver again, the process can read the code from the first sector of the hard disk, place it in the information space in RAM, and then go to this address.

This predefined sequence (the beginning of the CPU, loading the disk) allows programmers to start adding more and more code in the early stages of starting the CPU, which over time can ultimately run very complex programs.

In a modern world with complex peripheral devices, advanced processor architectures and huge resources (GB or RAM, TB Disk and very fast processors), the operating system can support quite powerful abstractions for the developer (several processes, virtual memory, downloadable drivers, etc.) .

But for a simple system with limited resources, you really do not need much for the "OS".

As a simple example, many small controllers have very small "OS", and some of them can simply be considered a "monitor", offering a little more than simple access to the serial port (or terminal or LCD), Of course, in these conditions there is not much need for a large operating system.

But also consider something like the classic Fort system. Here you have a system with an “OS” that gives you disk I / O, console I / O, memory management, as well as the actual programming language, as well as assembler, and it holds less than 8 KB of memory on an 8-bit machine.

or the old days of CP / M with its BIOS and BDOS.

CP / M is a good example of where a simple OS works well as an abstraction layer to allow portable programs to run on a huge set of hardware, but even then the system took up less than 8 KB of RAM to start and run.

Away from MB of memory used by modern OS. But, to be fair, we have MB memory, and our life is much simpler (mostly) and much more functional because of this.

Writing an OS is fun because it is interesting for HARDWARE to print "Hello World" by dragging 1 byte data during some obscure I / O port or stuffing it onto some kind of magic memory address.

Get the x86 emulator and release it so that the boot sector says your name. This is an ingenious pleasure.

+9
Dec 31 '09 at 19:03
source share

Basically ... your computer can just start the disk, because:

The BIOS includes this disk device in boot order.

When booting, the BIOS scans all boot devices in order, such as a floppy drive, hard drive, and CD. Each device accesses its media and checks for a hard-coded location (usually a sector on a disk or CD) for a fingerprint that identifies the medium and indicates the location to go to the disk (or medium) where the instructions begin. The BIOS tells the device to move its head (or something else) to the specified location on the media and read a large piece of instructions. The BIOS sends these instructions to the CPU.

The processor executes these instructions. In your case, these instructions are about to start Ubuntu OS. They can also be instructions for stopping or adding 10 + 20, etc.

As a rule, the OS starts up, taking a large chunk of memory (again, directly from the CPU, since library commands, such as "GlobalAlloc", etc., are unavailable because they are provided by the unloaded OS) and starts creating structures for the OS itself.

The OS provides a bunch of "features" for applications: memory management, file system, I / O, task scheduling, network connectivity, graphics management, access to printers, etc. This is what it does before you “get control”: creating / starting all services, so later applications can work together and not stomp each other in memory and have a good API for the provided OS.

Each feature provided by the OS is a big topic. The OS provides them with everything, so applications just have to worry about calling the right OS library, and the OS manages situations, for example, if two programs try to print at the same time.

For example, without an OS, each application must deal with a situation where another program is trying to print, and "do something," like printing in any case, or cancel another job, etc. Instead, just the OS to handle this, applications simply tell the OS to “print this stuff,” and the OS ensures that one application will print, and all other applications just need to wait until the first one completes or the user cancels it.

The smallest number of bytes that an OS should be does not really make sense, since "OS" can mean many or very few functions. If all you wanted to do was run the program from a CD, that would be very few bytes. However, this is not an OS. The task of the OS is to provide services (I call them functions) to allow the launch of many other programs, as well as to control access to these services for programs. This is complicated, and the more common resources you add (networks, and Wi-Fi, and CD recorders, and joysticks, and iSight videos, and two monitors, etc. Etc.), the more difficult it becomes .

+4
Dec 31 '09 at 20:24
source share
+3
Dec 31 '09 at 18:52
source share

One of the most recent operating system projects I have seen that has serious support was an MS Research project called Singularity , which is completely written in C # .NET from scratch.

To understand how much work is required, there are 2 main developers, but at any given time they have up to a dozen interns, and they still need two years before they can even force the OS to this extent, will load and display BMP images (how they use their presentations). This took a lot more work before they could even get to the point where the command line was (for example, about 4yrs).

+3
Dec 31 '09 at 18:57
source share

Basically, there are many arguments that the OS is actually - . If you all agree that the OS is specific (is it just the kernel? Does everything work in kernel mode?) Is it part of the operating system shell? X part of the OS? Is a web browser part of the OS?), Your question is answered! Otherwise, there is no specific answer to your question.

+2
Dec 31 '09 at 18:46
source share

You can get the book Development and Implementation of the FreeBSD Operating System for a very detailed answer. You can get it from Amazon or this link to the FreeBSD.org site looks like a book, as I remember it: link text

+2
Dec 31 '09 at 19:19
source share

I can’t believe it wasn’t mentioned ... but the classic book for reviewing the design of the operating system Operating Systems - Design and Implementation , written by Andrew S Tanenbaum, creator of MINIX. Many examples in the book focus directly on MINIX.

If you want to know a little more, Dev is a great place to start. Especially the wiki. This site is full of information, as well as developers who write personal operating systems for a small project / hobby. This is an excellent training resource, since on the same boat as on OSDev, there are many people who want to find out what is included in the OS. In the end, you can also try yourself!

+2
Jan 01 '09 at 9:26
source share

an operating system (OS) is a layer of software that controls hardware. The simpler the hardware, the simpler the OS and vice versa -)

If in the early days of microcomputers you can put the OS in 16K ROM and hard-plug the motherboard to start executing machine code instructions at the beginning of the ROM address space. This “bootstrap” process will then download the driver code for other devices, such as a keyboard, monitor, floppy drive, etc., And after a few seconds your computer will be booted and ready to use.

Currently ... the same principle, but much more sophisticated equipment; -)

+1
Dec 31 '09 at 18:51
source share

Oh, this is fun. I did all this at one time or another and was there through most of evolution.

In general, you start writing a new OS by launching a small one. The simplest thing is the bootloader, which is a small piece of code that draws in a piece of code and runs it. Once with Nova or PDP computers, you could enter the bootloader through the front panel: you entered the hexadecimal number of the instruction by the hexadecimal number. Boot loader than reading some media into memory, and set the program counter to the starting address of this code.

This piece of code usually loads something else, but it does not need it: you can write a program designed to run on bare metal. Such a program does something useful in and of itself.

The real operating system is larger and has more pieces. You need to load programs, put them in memory and run them; You need to provide code to run I / O devices; as it gets bigger, you need to manage your memory.

If you really want to know how this works, find the books Doug Comer Xinu and Andy Tannenbaum the new operating system book on Minix .

+1
Dec 31 '09 at 18:52
source share

Try How to Boot Computers , the Kernel Boot Process, and other related articles from the same blog for a quick overview of what the computer does at boot.

What does a computer do when its beginning is heavily dependent (perhaps obviously?) On CPU design and other "low-level things"; therefore, it is difficult to predict what your computer does at startup.

+1
Dec 31 '09 at 19:53
source share

Well, you have something to do with launching the chip on the “BIOS”, and then on the OS, which is usually a very difficult task performed by many code services.

If you REALY want to know more about this, I would advise you to read a book ... about micro-converters, especially where you create a small OS in c for 8051, etc ... or study the x86 assembly and create a very small "OS bootloader. "

0
Dec 31 '09 at 18:52
source share

You might want to check out this question .

0
Dec 31 '09 at 19:33
source share

The OS is a program, like any other application that you write. The main purpose of this program is that it allows you to run other programs. Modern OSs use modern hardware to ensure that programs do not collide with each other.

If you are interested in writing your own OS, check out your question:

How to get started in developing an operating system

0
Dec 31 '09 at 20:28
source share

You ask how a few bytes you could put on a disk and still work as an OS ? The answer depends on what you expect from your OS, but the smallest useful OS I know is 1.7 megabytes. This is the Tom Root Boot drive , and it is a very good small OS with rescue applications that are suitable for a single floppy disk . Back in the days when each machine had a floppy drive, and not every machine had a CD-ROM drive, I often used it.

0
Dec 31 '09 at 22:54
source share

I think this is like your own life. Firstly, you know very little - enough to get along. This is similar to what the BIOS provides - it knows enough to search for a drive and read information. Then you learn a little more when you go to elementary school. This is similar to loading and managing the boot sector into memory. Then you go to high school, which is similar to loading the kernel of the OS. Then you go to college (drivers and other apps.) Of course, this is the moment you are exposed to CRASH. HE HE.

The bottom line is that layers with more and less ability are slowly loading. There is nothing magical about the OS.

0
Jan 01 '09 at 3:56
source share

Reading here will give you an idea of ​​what you need to create Linux https://netfiles.uiuc.edu/rhasan/linux/

0
Jan 01 '09 at 9:17
source share

Another very small operating system that fits on a single drive is QNX (the last time I looked at it for a long time, the entire OS, with a GUI, a web browser, disk access and a built-in web server, a floppy drive) .

Since then, I have not heard too much about this, but it is a real-time OS, so it is developed very quickly.

0
Mar 18 '09 at 19:19
source share

In fact, some people attend 4-year college to get a general idea of ​​this.

0
Oct 08 '09 at 15:02
source share

At its core, the OS is very simple. Here's a beginner's guide to WHAT on a successful OS: 1. Control the processor using a scheduler that decides which process (executable program instance) is scheduled. 2. Manage memory to decide which all processes use it to store instructions (code) and data (variables). 3. Control I / O interfaces such as drives, alarms, keyboard, mouse. Now, more than three requirements give rise to the need for processes for communication (and not struggle!). To interact with the outside world, help applications do what they want to do. To delve into HOW it does, read the dinosaur book :)

So, you can make the OS as small as you want, as long as you manage to handle all the hardware resources. When you boot, the BIOS tells the CPU to start reading the bootloader (which loads the first OS function, which is located at a fixed address in memory - something like main () of a small C program). Then it creates functions, processes and threads and launches a big hack!

0
May 2 '14 at 17:55
source share

Firstly, reading and reading about what the OS is; then what are the applications / types / nature / purpose / needs / different OS. Some of the links are as follows: the novice will get these links:

Modern OS - this gives the idea of ​​a common OS.

The beginning of the OS - this gives the basics of what is really needed for the MAKE OS, how we can do it and how we can modify the presentation of the OS open source code ourselves.

Wiki OS - gives an idea of ​​the different Os used in different fields and its use (objects / functions of the OS.)

Look, in general, which OS contains (not complicated Linux or Windows)

The OS needs a processor, and to reset the code in it you will need a bootloader . The OS must have goals for filling, and these goals must be defined in a shell called Kernel Inside you can have scheduling time and ISR's (it depends on the goal and OS you need to do)

0
Dec 15 '16 at 16:23
source share

OS development is complicated. There are some websites like osdev or lowlevel.eu (German) dedicated to this topic. There are also some books that others have already mentioned.

I cannot but mention the series of videos “Write your own operating system” on YouTube, since I did this :-)

See https://www.youtube.com/playlist?list=PLHh55M_Kq4OApWScZyPl5HhgsTJS9MZ6M

0
Mar 13 '17 at 11:51 on
source share



All Articles