Computer Science · Topic 08

Operating Systems

Discover how operating systems manage hardware, memory, processes, files, and devices while providing an environment for applications to run.

1. What Is an Operating System?

An operating system (OS) is system software that manages computer hardware and provides services for applications and users.

When you open a browser, save a document, or play music, the operating system helps coordinate the resources needed for those tasks.

Examples of operating systems

The operating system acts as a resource manager and provides a standard environment through which programs use the computer.

2. Main Functions of an Operating System

Process management Creates, schedules, and coordinates running programs.
Memory management Allocates memory and manages address spaces and virtual memory.
File management Organizes files and directories and controls access to stored data.
Device management Coordinates access to devices such as keyboards, displays, and storage.
Security and permissions Helps control access to accounts, files, devices, and system resources.
User interface Provides ways to interact with the system, such as a graphical desktop or command line.

3. Kernel and System Calls

The kernel is the core component of an operating system. It manages fundamental operations such as scheduling, memory, and access to hardware.

Applications generally request protected operating-system services through defined interfaces called system calls.

Application
     |
     v
Operating-system interface
     |
     v
Kernel
     |
     v
Hardware resources

For example, an application may request that the OS open a file. The operating system checks the request and permissions, then performs the appropriate operations.

This is a simplified model. Real operating systems may contain additional services, drivers, libraries, and security boundaries.

4. Programs, Processes, and Threads

Program

A program is a set of instructions stored for execution. By itself, a program file is not necessarily running.

Process

A process is a running instance of a program, together with the resources and execution state managed for it.

Thread

A thread is a sequence of execution within a process. A process can have one or multiple threads.

Process: Web Browser
    |
    |-- Thread 1: Interface work
    |-- Thread 2: Background task
    |-- Thread 3: Page processing

This is a conceptual illustration. Actual browser architecture varies and may use multiple processes as well as multiple threads.

5. Process States

A process can move through different states during its lifetime. A simplified model includes the following:

StateMeaning
New The process is being created.
Ready The process can run but is waiting for CPU time.
Running The process is currently executing on a CPU core.
Waiting / Blocked The process is waiting for an event, such as an I/O operation.
Terminated The process has finished or has been stopped.
New → Ready → Running → Terminated
             ^      |
             |      v
             └── Waiting

State transitions depend on events such as scheduling decisions, I/O completion, and process termination.

6. CPU Scheduling

A CPU scheduler chooses which eligible process or thread should run next. Scheduling helps share processor time among competing tasks.

Common scheduling algorithms

Example: Round Robin

Time slice = 2 units

Process A runs for up to 2 units
Process B runs for up to 2 units
Process C runs for up to 2 units
Then the scheduler cycles through remaining ready tasks.

Round Robin is useful for sharing CPU time responsively. The appropriate scheduling method depends on the system's goals.

7. Memory Management

Memory management controls how programs use main memory (RAM). The operating system tracks memory usage and provides processes with suitable address spaces.

Key concepts

Virtual memory is not the same as physical RAM. Using storage to support memory management is generally much slower than accessing RAM.

8. File Systems

A file system defines how files and directories are organized and how information about stored data is maintained.

Common file-system concepts

Examples of file systems

9. Device and I/O Management

The operating system coordinates input and output (I/O) between applications and devices.

Application requests printing
           |
           v
Operating system prepares print job
           |
           v
Print queue stores pending work
           |
           v
Printer processes the job

10. Deadlocks

A deadlock occurs when a set of processes are permanently waiting for resources or events that cannot become available because of the waiting relationships between them.

Four classic conditions

Under the classic resource-allocation model, all four conditions must hold for deadlock to be possible.

Ways systems handle deadlocks

11. Types of Operating Systems

Batch OS Processes groups of jobs with limited direct interaction during execution.
Time-sharing OS Shares processor time among users or tasks to support interactive use.
Real-time OS Designed to meet timing requirements within specified constraints.
Distributed OS Coordinates resources across multiple computers; the term can describe several different system designs.
Network OS Provides services for connected computers, such as shared resources and centralized administration.
Mobile OS Designed for mobile devices, including touch interfaces and power management.
These categories are not always mutually exclusive. One operating system can have characteristics of more than one category.

12. User Interfaces: GUI and CLI

Graphical User Interface (GUI)

A GUI lets users interact through visual elements such as windows, icons, buttons, menus, and touch controls.

Command-Line Interface (CLI)

A CLI accepts text commands. It is useful for automation, system administration, development, and tasks that benefit from precise commands.

GUICLI
Visual and often easier to discover.Text-based and often efficient for repetitive tasks.
Commonly uses windows, icons, and menus.Uses commands and their arguments.
Good for many everyday interactive tasks.Useful for scripting and remote administration.

Many operating systems provide both interfaces, and advanced users often use them together.

13. Knowledge Check

Try answering each question before revealing the answer.

1. What is the main purpose of an operating system?

To manage computer resources and provide services and an environment for applications and users.

2. What is the difference between a program and a process?

A program is a set of stored instructions; a process is a running instance with execution state and managed resources.

3. Which scheduling algorithm uses time slices?

Round Robin.

4. What is virtual memory?

A memory-management abstraction that gives processes address spaces and can use storage to support memory management.

5. Name the four classic deadlock conditions.

Mutual exclusion, hold and wait, no preemption, and circular wait.

6. What does a device driver do?

It provides software support for communication between the operating system and a particular device.

7. What is the difference between a GUI and a CLI?

A GUI uses visual controls, while a CLI lets users interact through text commands.

Key Takeaways