Operating system structure, services and system calls — Unit 1 Notes (Operating Systems)

BCS401 · Unit 1

Operating system structure, services and system calls notes — Unit 1

Free unit-wise study notes on operating system structure, services and system calls for Operating Systems, Semester 4 of B.Tech — Computer Science & Engineering — key concepts, examples, important questions and a revision checklist for semester exams.

An introduction to what an Operating System is and how it bridges hardware and software. Covers OS evolution, architectures (Monolithic vs. Microkernel), Dual-Mode operation, and the mechanism of System Calls.

Notebook — 12 pages

Page 1

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

1. What is an Operating System?

An Operating System (OS) is the fundamental software program that manages computer hardware and provides a platform for application programs to run.

1.1 The Two Primary Roles

  • Resource Manager: The hardware (CPU, Memory, Disk, Network) is a limited resource. The OS acts as a fair referee, deciding which program gets to use the CPU, how much memory it gets, and when it can access the hard drive, preventing chaos and crashes.
  • Extended Machine (Abstraction): Hardware is ugly and complicated to program (e.g., spinning up a disk motor just to read a byte). The OS provides a clean, abstract, and beautiful interface (like a 'File') so programmers don't need to worry about hardware specifics.

Next — Evolution of Operating Systems

1 of 12

Page 2

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

2. Evolution of Operating Systems

Operating Systems evolved dramatically as hardware improved.

  • Batch Systems (1950s): No direct user interaction. Jobs were submitted on punch cards. The OS simply loaded one job, ran it to completion, and loaded the next. Very inefficient, as the CPU sat idle while reading cards.
  • Multiprogrammed Systems: The OS keeps multiple jobs in memory simultaneously. If Job A needs to wait for I/O (like reading a disk), the OS instantly switches the CPU to Job B. Maximizes CPU utilization.
  • Time-Sharing (Multitasking) Systems: An extension of multiprogramming. The CPU switches between multiple jobs so quickly (every few milliseconds) that multiple users can interact with the system simultaneously, creating the illusion that each user has their own dedicated computer.
  • Distributed Systems: Multiple independent computers connected via a network, appearing to the user as a single coherent system.
  • Real-Time Systems (RTOS): Systems with strict, rigid time constraints. Processing must happen within a defined deadline, or the system fails entirely (e.g., Car airbag deployment systems, Pacemakers).

Next — Dual-Mode Operation

2 of 12

Page 3

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

3. Dual-Mode Operation

To protect the hardware from malicious or buggy programs, the OS relies on a hardware-level security feature called Dual-Mode operation.

A special bit in the CPU hardware (the Mode Bit) indicates the current mode:

  • User Mode (Mode Bit = 1): The CPU restricts certain dangerous instructions. Application programs (like Chrome or a Python script) run here. If a user program tries to execute a dangerous instruction, the CPU traps it and crashes the program.
  • Kernel Mode (Mode Bit = 0): Also called Supervisor or Privileged Mode. The CPU has unrestricted access to all hardware and instructions. The Operating System code runs here.

How do user programs do anything useful if they are restricted? They must politely ask the OS to do it for them via a System Call.

Next — System Calls

3 of 12

Page 4

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

4. System Calls

A System Call is the programmatic interface that a User Mode application uses to request a service from the Kernel Mode OS.

4.1 The Mechanism

When a C program calls `printf()`, it eventually triggers a system call (like `write()` in Linux):

  • 1. The user program places arguments for the system call into specific CPU registers.
  • 2. The program executes a special software interrupt instruction (e.g., `TRAP` or `INT 0x80`).
  • 3. Mode Switch: The CPU hardware switches the mode bit from 1 to 0 and jumps to a fixed location in the OS kernel.
  • 4. The OS examines the registers to see which system call was requested, verifies the arguments, and performs the privileged action (e.g., writing to the screen).
  • 5. The OS switches the mode bit back to 1 and returns control to the user program.

Next — Types of System Calls

4 of 12

Page 5

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

5. Types of System Calls

System calls are grouped into five major categories based on the OS services they request.

  • 1. Process Control: Create, terminate, or pause a program.
    (Linux: `fork()`, `exit()`, `wait()` | Windows: `CreateProcess()`, `ExitProcess()`)
  • 2. File Management: Create, read, write, or delete files.
    (Linux: `open()`, `read()`, `write()`, `close()`)
  • 3. Device Management: Request access to hardware devices like printers or USB drives.
    (Linux: `ioctl()`)
  • 4. Information Maintenance: Get system time, date, or system data.
    (Linux: `getpid()`, `sleep()`)
  • 5. Communications: Create network connections or send messages between processes.
    (Linux: `pipe()`, `shmget()`, `mmap()`)

Next — OS Architecture: Monolithic

5 of 12

Page 6

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

6. OS Architecture: Monolithic Kernels

How do you organize the millions of lines of code that make up an OS? The architecture dictates this.

6.1 Monolithic Architecture

The entire operating system—file management, memory management, process scheduling, and device drivers—runs entirely in Kernel Mode as a single, massive program.

  • Pros: Extremely fast. Since all components are in the same memory space, they can communicate with each other instantly via simple function calls.
  • Cons: Difficult to maintain. A bug in a minor component (like a poorly written audio driver) can crash the entire kernel, causing a "Blue Screen of Death" or Kernel Panic.
  • Examples: Linux, MS-DOS, original Unix.

Next — OS Architecture: Microkernel

6 of 12

Page 7

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

7. OS Architecture: Microkernels

A reaction to the bloat of monolithic kernels.

7.1 Microkernel Architecture

The OS is stripped down to the bare minimum. The Kernel Mode code only handles basic process scheduling and basic memory management.

Everything else—file systems, network stacks, and device drivers—is moved out of the kernel and runs as standard User Mode programs.

  • Pros: Highly stable and secure. If an audio driver crashes, it just kills that one user-mode process. The rest of the OS continues running smoothly. Very easy to extend.
  • Cons: Performance overhead. Because components are isolated, they must communicate via message passing through the microkernel, which requires constant context switching between User and Kernel modes.
  • Examples: QNX, Minix, Mach (which influenced macOS).

Note: Modern operating systems like Windows NT and macOS use a Hybrid approach, blending the speed of a monolith with the modularity of a microkernel.

Next — Virtual Machines

7 of 12

Page 8

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

8. Virtual Machines

A Virtual Machine (VM) takes the layered approach to its logical conclusion. It completely abstracts the hardware, creating an illusion of multiple independent computers running on a single physical machine.

8.1 The Hypervisor (VMM)

The Virtual Machine Monitor (Hypervisor) sits directly on the hardware (or on a Host OS). It creates and manages "Guest" operating systems.

  • Type 1 (Bare-Metal): The Hypervisor is the OS. It runs directly on the hardware. Highly efficient. (e.g., VMware ESXi, Microsoft Hyper-V). Used in cloud data centers.
  • Type 2 (Hosted): The Hypervisor runs as an application inside a normal Host OS (like Windows). (e.g., VirtualBox, VMware Workstation).

When a Guest OS tries to execute a privileged instruction (like writing to disk), the Hypervisor intercepts it, simulates the hardware response, and returns control to the Guest.

Next — System Boot Process

8 of 12

Page 9

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

9. The System Boot Process

When you press the power button, RAM is completely empty. How does the CPU know how to load the OS?

  • 1. Power-On: The CPU is hardwired to look at a specific physical memory address on the motherboard's ROM (Read-Only Memory) chip.
  • 2. POST (Power-On Self Test): A tiny program called the BIOS (Basic Input/Output System) or UEFI runs. It checks if RAM, keyboard, and disk drives are functioning.
  • 3. Bootloader: The BIOS looks at the very first sector of the Hard Drive (the Master Boot Record or MBR). It loads a tiny program called the Bootloader (like GRUB in Linux) into RAM.
  • 4. Kernel Loading: The Bootloader is smart enough to understand file systems. It locates the massive OS Kernel file (e.g., `vmlinuz` or `ntoskrnl.exe`), loads it into RAM, and hands over control.
  • 5. OS Initialization: The Kernel initializes its data structures, starts background services (daemons), and eventually displays the login screen.

Next — Operating System Services

9 of 12

Page 10

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

10. Operating System Services

An OS provides an environment for the execution of programs. It provides specific services to the programs and to the users of those programs.

10.1 Services for the User

  • User Interface (UI): CLI (Command Line Interface) or GUI (Graphical User Interface).
  • Program Execution: Loading a program into memory and running it.
  • I/O Operations: Hiding the complexity of controlling hardware devices.
  • File System Manipulation: Creating, reading, writing, and organizing files into directories.

10.2 Services for System Efficiency

  • Resource Allocation: Managing CPU cycles, memory, and file storage across multiple competing users.
  • Accounting: Keeping track of which users use how much computing resources.
  • Protection and Security: Ensuring that one user cannot interfere with another user's files or processes.

Next — System Programs

10 of 12

Page 11

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

11. System Programs

System Programs (also known as System Utilities) provide a convenient environment for program development and execution. They bridge the gap between the complex System Calls and the User Interface.

Most users' view of the operating system is actually defined by system programs, not the actual system calls.

11.1 Categories

  • File Management: Programs to create, delete, copy, and rename files. (e.g., Windows Explorer, Linux `cp`, `rm`).
  • Status Information: Programs that ask the system for the date, time, available memory, or disk space. (e.g., Task Manager, `top`).
  • File Modification: Text editors to create and modify files. (e.g., Notepad, `vim`).
  • Programming-Language Support: Compilers, assemblers, debuggers, and interpreters provided with the OS.
  • Program Loading and Execution: Loaders and linkage editors.
  • Communications: Programs for virtual connections among processes, users, and computer systems. (e.g., web browsers, SSH).

Next — Summary Checklist

11 of 12

Page 12

Wink Notes

B.Tech CSE — 4th Semester

Operating Systems

Unit - 1

12. Summary Checklist

Unit 1 sets the foundation by explaining why the OS exists and how it protects the hardware.

12.1 University Exam Checklist

  • Define an Operating System and state its two primary functions.
  • Explain Multiprogramming and Time-Sharing.
  • What is Dual-Mode operation? Why is it necessary?
  • What is a System Call? Explain the exact sequence of events that occurs when a system call is made.
  • Differentiate between Monolithic and Microkernel architectures. Give an example of each.
  • Explain the difference between a Type 1 and Type 2 Hypervisor.
  • Describe the system boot process from Power-On to OS Initialization.

12 of 12

Continue in this subject