Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What Does an OS Actually Do?

What exactly does an operating system do? I know that operating systems can be programmed, in, for example, C++, but I previously believed that C++ programs must be run under an operating system? Can somebody please explain and give links? thanks in advance, ell

like image 521
Ell Avatar asked May 05 '10 20:05

Ell


4 Answers

An operating system is a layer between your code (user code) and the hardware.

The OS is responsible for managing the physical components and giving you a simple (hopefully) API off of which to build. It handles which programs run, when, who goes first, how memory is handled, who gets memory, video drawing, and all that good stuff.

For example, when making a GUI, instead of you sending each bit to the monitor, you tell the OS (or window manager) to make a window. You then tell it to place a button in your window. The OS then handles drawing the window, moving the window, moving the button (but keeping it where it should be in the window).

Now, you can program an operating system in C++, but it's not easy. You have to develop your kernel and whatnot, find a way to interface with the hardware, then expose that interface to your users and their programs.

So, essentially, an OS handles software-to-hardware interfacing and manages your physical resources. C++ programs can be run in an OS or, with enough work, run by themselves or even be an OS.

like image 93
ssube Avatar answered Oct 12 '22 02:10

ssube


Actually, the C++ standard itself has something to say on this issue. §1.4/7:

Two kinds of implementations are defined: hosted and freestanding. For a hosted implementation, this International Standard defines the set of available libraries. A freestanding implementation is one in which execution may take place without the benefit of an operating system, and has an implementation-defined set of libraries that includes certain language-support libraries (17.4.1.3).

And in 17.4.1.3,

A freestanding implementation has an implementation-defined set of headers. This set shall include at least the following headers, as shown in Table 13:

Table 13—C++ Headers for Freestanding Implementations
_______________________________________________
 Subclause Header(s)
 18.1 Types    <cstddef>   
 18.2 Implementation properties    <limits>
 18.3 Start and termination    <cstdlib>
 18.4 Dynamic memory management    <new>
 18.5 Type identification  <typeinfo>  
 18.6 Exception handling   <exception> 
 18.7 Other runtime support    <cstdarg>   

The supplied version of the header shall declare at least the functions abort(), atexit(), and exit() (18.3).

These headers either define constants or provide basic support to the compiler. In practice, some language features will be missing until the OS completes some initialization, for example new and catch.

like image 27
Potatoswatter Avatar answered Oct 12 '22 02:10

Potatoswatter


An OS is really just a program that runs other programs and manages hardware resources for them.

If you are really serious about getting into the internals, I'd recommend reading the book Understanding the Linux Kernel.

like image 30
Kristopher Johnson Avatar answered Oct 12 '22 03:10

Kristopher Johnson


sure, http://en.wikipedia.org/wiki/Operating_system

An operating system is the software on a computer that manages the way different programs use its hardware, and regulates the ways that a user controls the computer. Operating systems are found on almost any device that contains a computer with multiple programs—from cellular phones and video game consoles to supercomputers and web servers. Some popular modern operating systems for personal computers include Microsoft Windows, Mac OS X, and Linux (see also: list of operating systems, comparison of operating systems).

I mean the description of an operating system, what it does when and why goes far beyond an answer on this site imho.

like image 43
Gregory Pakosz Avatar answered Oct 12 '22 02:10

Gregory Pakosz