1. Home
  2. Explore
  3. Computer Science
  4. Operating Systems Fundamentals

Study methods

Flashcards
Quiz
Fill in the blanks
Written test
Lesson
Notes
Podcast
Content

Operating Systems Fundamentals

Operating Systems: Structure, Abstraction, and Resource Management

Where the operating system fits

A computer system can be understood as a set of layers, with each layer built on the ones below it:

  1. Transistors and basic circuit elements: At the physical level, computers contain millions or billions of transistors, commonly made using CMOS technology. Transistors are combined to create digital logic gates, such as AND, OR, and XOR gates. This level also includes components such as memory cells, flip-flops, and registers.

  2. Organized hardware units: Basic circuit elements are assembled into functional units, including memory, RAM, instruction-fetch units, and decoding units.

  3. Physical hardware: These organized units make up the computer’s hardware, such as its processor, memory, storage devices, network interface, and display hardware.

  4. Operating system: The operating system sits between the hardware and the applications. It mediates their interactions and provides services to applications.

  5. Applications: Programs such as office software, web browsers, games, and compilers use the operating system to perform tasks.

The operating system has two central responsibilities: hardware abstraction and resource management. Abstraction makes hardware easier for software to use, while resource management coordinates access to hardware that must be shared.


Hardware abstraction

Why hardware needs to be abstracted

Hardware is complex and differs between systems. A program that directly controlled hardware would need to know details such as:

  • Where data is stored in memory.

  • How the processor communicates with a graphics device.

  • How display coordinates, colors, and other screen properties are represented.

  • How information must be formatted for a particular graphics card or monitor.

These details can change when hardware changes. A program written to control one graphics card or monitor directly might not work correctly with another. Requiring every application to manage these details would make software difficult to write, maintain, and move between computers.

The operating system abstracts these hardware-specific details by providing applications with simpler, more consistent ways to request services.

Example: displaying “Hello World”

Consider a C program that uses printf to display the string “Hello World.” The string is stored in memory, and the program passes a reference to it to the printing function. Displaying the string involves more than simply sending those characters to the monitor:

  1. The string is held in main memory, also called RAM.

  2. Processor instructions read the characters from memory, typically moving data through processor registers.

  3. The characters and associated display information are placed in a video buffer. The information may include the string’s color, its horizontal and vertical position, and other display attributes.

  4. Graphics hardware reads the relevant information and produces the image shown on the monitor.

The details of this process depend on the particular processor, graphics hardware, and display. An application that handled each step itself would need to understand those devices and their requirements.

Instead, an application makes a higher-level request. A function such as printf can ultimately use an operating-system service, commonly through a system call. The operating system then coordinates the work required to communicate with the relevant hardware. The application’s programmer does not need to specify all the low-level display details.

Benefits of abstraction

  • Simpler application development: Programmers can use higher-level operations without managing hardware details directly.

  • Reusable operating-system functionality: Applications can rely on common OS services rather than each implementing its own hardware-control routines. For example, many applications can use the same system facilities for output.

  • Portability: An application can often run on different hardware without being rewritten, provided an appropriate operating system and software environment are available. The operating system handles differences between the underlying devices.

Abstraction therefore creates a more stable boundary between applications and hardware. Applications request what they need, while the operating system determines how to carry out the request on the specific system.


Resource management

Why resources must be managed

A computer contains limited resources, including:

  • CPU time for executing instructions.

  • Main memory for holding programs and their data while they run.

  • Network devices for sending and receiving information.

  • Secondary storage, such as hard disks.

  • Input and output devices, including monitors.

A computer may run several applications at nearly the same time—for example, a browser, a compiler, a game, and a presentation program—even though it has a limited number of processors, a finite amount of memory, and only a small number of other devices. The operating system coordinates access so that multiple applications can share these resources.

The OS must also protect applications from one another. Sharing should allow useful access to common hardware without allowing one application to interfere with another or inspect its private data.

CPU sharing and scheduling

The operating system decides which application runs on the processor and when. This decision-making is called CPU scheduling.

A simple approach is to let one application use the CPU until it finishes, then start the next application. Under this approach, if Application 1 is running, Application 2 must wait until Application 1 completes. Although straightforward to implement, this can make poor use of the system: one application may occupy the processor while other applications remain unable to make progress.

Operating systems therefore need more effective ways to share processor time among applications. Modern systems coordinate CPU use so that multiple programs can make progress, even when the computer has only a limited number of processors.

Main-memory sharing

An application generally needs to be present in RAM to execute. Because RAM is limited, the operating system must manage how it is used by the applications running on the system.

Memory management is not only a matter of allocating space. The OS must also ensure that applications are kept separate. Each application should operate in an isolated environment so that it cannot freely read or overwrite another application’s memory.

Isolation and protection

Isolation prevents one application from improperly observing or affecting another. It is important for both reliability and security.

For example, a web browser may contain sensitive banking information, such as passwords or credit-card details. At the same time, a separate game or other program could be malicious. Without isolation, the malicious program might be able to inspect the browser’s data and steal that information. The operating system uses protection mechanisms to restrict what each application can access.

A protected, separated environment is sometimes described as a sandbox. Applications can share the same physical computer while being prevented from freely accessing one another’s data or resources.


Operating systems for different purposes

Operating systems are used in many kinds of devices. Their designs reflect the demands of the systems and applications they support.

Embedded operating systems

Embedded systems often operate with strict limits on memory, processing capacity, and power. An embedded OS such as Contiki is designed for constrained devices, including wireless sensor nodes used in the Internet of Things.

For these systems, the operating system must manage limited resources while keeping power consumption low.

Mobile operating systems

Examples of mobile operating systems include Android, iOS, Ubuntu Touch, and Windows Touch. Like embedded operating systems, mobile OSs must consider power use because a phone or similar device depends on a finite battery charge.

Mobile operating systems also support user interaction through devices such as LCD screens and keypads. This distinguishes them from many embedded systems that do not provide the same kind of direct interaction with a user.

Real-time operating systems

A real-time operating system (RTOS) is designed for applications in which completing an operation within a required time is essential. Examples include QNX, VxWorks, and RT Linux.

RTOSs are used in time-critical and safety-critical settings, such as some systems in rockets, automobiles, and nuclear plants. In these contexts, an operation that finishes too late may be as serious as one that produces an incorrect result. An RTOS is therefore designed to ensure that critical operations complete within specified timing limits.

Operating systems for secure environments

Some operating systems are designed with particular emphasis on security. Examples include SELinux and seL4. They may be used in settings where protecting data and restricting unauthorized access are especially important, such as servers hosting banking software.

Server and desktop operating systems

Server operating systems include products such as Red Hat, Ubuntu, and Windows Server. Desktop operating systems include macOS, Windows, and Ubuntu.

Server and desktop systems can share many general features, but their operating systems may manage applications and system resources differently to suit their intended uses.


xv6 as a teaching operating system

xv6 is a small operating system designed for teaching. It is well documented and comparatively easy to understand, making it useful for studying how operating systems are structured and how their mechanisms work.

xv6 is designed to resemble Version 6 of UNIX. Its organization therefore provides a manageable way to learn concepts that also appear in UNIX-like systems, including Linux. Studying xv6 can help explain the principles behind more complex modern operating systems.

Ask anything

We've read this whole study set, so questions about it get the best answers.

FlashcardsQuizFill in the blanksWritten testLessonNotesPodcastContent