Tuesday, January 6, 2026

OS UNIT-I

 

                                                                     UNIT-I          

Operating Systems Overview: Introduction, Operating system functions, Operating systems operations, Computing environments, Free and Open-Source Operating Systems

System Structures: Operating System Services, User and Operating-System Interface, system calls, Types of System Calls, system programs, Operating system Design and Implementation, Operating system structure, Building and Booting an Operating System, Operating system debugging

 

OPERATING SYSTEMS OVERVIEW

 

·         An operating system is a program that manages a computer’s hardware.

·         It also provides a basis for application programs and acts as an intermediary between

the computer user and the computer hardware.

·         An amazing aspect of operating systems is how they vary in accomplishing these

tasks. Mainframe operating systems are designed primarily to optimize utilization of

·         hardware. Personal computer (PC) operating systems support complex games,

·         business applications, and everything in between.

Operating systems for mobile computers provide an environment in which a user can

easily interface with the computer to execute programs.

·         Thus, some operating systems are designed to be convenient, others to be efficient,

and others to be some combination of the two.

 

Introduction: An Operating System (OS) is system software that acts as an interface between the user and the computer hardware.

It manages hardware components, controls system operations, and provides an environment for running applications.

Key idea:

OS = User ↔ Hardware (Controller + Manager)

 

Primary Goals:

Convenience: Make computer systems easier to use.

Efficiency: Use hardware resources effectively.

Security: Protect system data and users.

Reliability: Ensure stable and error-free operation.

 

 

OPERATING SYSTEM FUNCTIONS

 

An Operating System (OS) is software that acts as a bridge between the user and the computer hardware. It provides an environment where users can execute programs efficiently and conveniently.

  • Manages and controls all computer resources.
  • Provides services and resources to user programs.
  • Coordinates and monitors program execution to prevent errors.
  • Offers a user interface (virtual machine) and hides software complexity.
  • Supports multiple execution modes for programs.




FUNCTIONS OF AN OPERATING SYSTEM

 

1. Process Management

Process management in operating system is about managing processes. A Process is a running program. The life cycle of process is from the moment program start until it finishes.

 


Core Functions in Process Management:

  • Scheduling: Decides which process uses the CPU next (using algorithms like Round Robin or Priority Scheduling).
  • Synchronization: Ensures orderly execution using locks, semaphores, or monitors to prevent race conditions.
  • Deadlock Handling: Detects and prevents situations where processes wait forever for resources.
  • Inter-Process Communication (IPC): Allows processes to exchange data via shared memory or message passing.

 

2. Memory Management

Memory management in an operating system controls how data is stored and organized in main (primary) memory and secondary storage, ensuring programs get the memory they need and freeing it when no longer used.



 Key Activities in Memory Management:

  • Allocation & De-allocation: Assigns and frees memory as needed.
  • Protection: Prevents processes from interfering with each other’s memory..
  • Virtual Memory: Uses disk space as extra memory to run large programs.
  • Fragmentation Handling: Reduces wasted space through compaction.
  • Disk Management: Handles file storage, free space, disk scheduling, and backups.

 

3. File System Management

File management in an operating system organizes and controls how data is stored, named, and accessed on storage devices, making it easy for users to find and use their files.

 


File System Management includes managing of:

  • File Attributes: Name, type, size, and permissions.
  • File Types: Text, binary, and executable files.
  • Operations: Create, read, write, and delete files.
  • Access Methods: Sequential, direct, and indexed access for faster retrieval.

 

4. Device Management (I/O System)

Device management in an operating system controls how the computer communicates with hardware devices like printers or disks, using drivers and techniques to ensure smooth and efficient operation.



Major components in Device Management:

  • Device Drivers: Interface between hardware and OS.
  • Buffering & Caching: Temporarily store data to match device speeds and improve performance.
  • Spooling: Spooling manages data waiting to be processed, particularly in devices like printers. The OS places print jobs in a spool (a temporary storage area), allowing the CPU to continue other tasks while the printer works through the queue.

 

 

5. Protection and Security

Protection and security mechanisms in an OS are designed to safeguard system resources from unauthorized access or misuse. These mechanisms control which processes or users can access specific resources (such as memory, files, and CPU time). It also ensures that only authorized users can perform specific actions.

 


 

 

The OS protects system resources and user data from unauthorized access and attacks.

  • Access Control: Limits user and process permissions.
  • Authentication: Verifies users through credentials (UIDs/SIDs).
  • Resource Protection: Prevents misuse of files, memory, or devices.
  • Security: Guards against malware, denial-of-service attacks, and data theft.

 

 

OPERATING SYSTEMS OPERATIONS

These are the internal activities performed by an OS to keep the computer system running smoothly.

1. Process Management Operations

·         Creating and terminating processes

·         Scheduling processes (CPU scheduling: FCFS, SJF, Round Robin, etc.)

·         Switching between processes (context switching)

·         Handling deadlocks

·         Managing process communication (IPC)

2. Memory Management Operations

·         Allocating and deallocating memory to programs

·         Keeping track of used/free memory

·         Swapping (moving processes between RAM and disk)

·         Managing virtual memory (demand paging, page replacement)

3. Storage / File Management Operations

·         Creating, reading, writing, renaming, deleting files

·         Organizing files into directories

·         Managing file permissions

·         Allocating space on disk

·         Ensuring data consistency on storage devices

4. I/O Operations

·         Handling input/output devices

·         Using device drivers to control hardware

·         Buffering, spooling, caching

·         Managing interrupts

·         Scheduling I/O requests

5. Protection and Security Operations

·         Setting user permissions

·         Authentication (passwords, biometrics)

·         Preventing unauthorized access

·         Protecting memory and data

·         Monitoring system activity for threats

6. Networking Operations

·         Managing network connections

·         Sending/receiving data packets

·         Protocol handling (TCP/IP)

·         Network resource sharing (printers, files)

7. System Monitoring and Accounting

·         Tracking resource usage (CPU, memory, I/O)

·         Maintaining logs

·         Managing users and sessions

·         Accounting for usage (important in servers)

COMPUTING ENVIRONMENTS

Computing environments refer to the technology infrastructure and software platforms that are used to develop, test, deploy, and run software applications. There are several types of computing environments, including:

  1. Mainframe: A large and powerful computer system used for critical applications and large-scale data processing.
  2. Client-Server: A computing environment in which client devices access resources and services from a central server.
  3. Cloud Computing: A computing environment in which resources and services are provided over the Internet and accessed through a web browser or client software.
  4. Mobile Computing: A computing environment in which users access information and applications using handheld devices such as smartphones and tablets.
  5. Grid Computing: A computing environment in which resources and services are shared across multiple computers to perform large-scale computations.
  6. Embedded Systems: A computing environment in which software is integrated into devices and products, often with limited processing power and memory.

Each type of computing environment has its own advantages and disadvantages, and the choice of environment depends on the specific requirements of the software application and the resources available.

In the world of technology where every tasks are performed with help of computers, these computers have become one part of human life. Computing is nothing but process of completing a task by using this computer technology and it may involve computer hardware and/or software. But computing uses some form of computer system to manage, process, and communicate information. After getting some idea about computing now lets understand about computing environments

Computing Environments: When a problem is solved by the computer, during that computer uses many devices, arranged in different ways and which work together to solve problems. This constitutes a computing environment where various number of computer devices arranged in different ways to solve different types of problems in different ways. In different computing environments computer devices are arranged in different ways and they exchange information in between them to process and solve problem. One computing environment consists of many computers other computational devices, software and networks that to support processing and sharing information and solving task. Based on the organization of different computer devices and communication processes there exists multiple types of computing environments

Now lets know about different types of computing environments. 

Types of Computing Environments: There are the various types of computing environments. They are :

 

 


  1. Personal Computing Environment : In personal computing environment there is a stand-alone machine. Complete program resides on computer and executed there. Different stand-alone machines that constitute a personal computing environment are laptops, mobiles, printers, computer systems, scanners etc. That we use at our homes and offices.
  2. Time-Sharing Computing Environment : In Time Sharing Computing Environment multiple users share system simultaneously. Different users (different processes) are allotted different time slice and processor switches rapidly among users according to it. For example, student listening to music while coding something in an IDE. Windows 95 and later versions, Unix, IOS, Linux operating systems are the examples of this time sharing computing environment.
  3. Client Server Computing Environment : In client server computing environment two machines are involved i.e., client machine and server machine, sometime same machine also serve as client and server. In this computing environment client requests resource/service and server provides that respective resource/service. A server can provide service to multiple clients at a time and here mainly communication happens through computer network.
  4. Distributed Computing Environment : In a distributed computing environment multiple nodes are connected together using network but physically they are separated. A single task is performed by different functional units of different nodes of distributed unit. Here different programs of an application run simultaneously on different nodes, and communication happens in between different nodes of this system over network to solve task.
  5. Grid Computing Environment : In grid computing environment, multiple computers from different locations works on single problem. In this system set of computer nodes running in cluster jointly perform a given task by applying resources of multiple computers/nodes. It is network of computing environment where several scattered resources provide running environment for single task.
  6. Cloud Computing Environment : In cloud computing environment on demand availability of computer system resources like processing and storage are availed. Here computing is not done in individual technology or computer rather it is computed in cloud of computers where all required resources are provided by cloud vendor. This environment primarily comprised of three services i.e software-as-a-service (SaaS), infrastructure-as-a-service (IaaS), and platform-as-a-service (PaaS).
  7. Cluster Computing Environment : In cluster computing environment cluster performs task where cluster is a set of loosely or tightly connected computers that work together. It is viewed as single system and performs task parallelly that's why also it is similar to parallel computing environment. Cluster aware applications are especially used in cluster computing environment.

Advantages of different computing environments:

  1. Mainframe: High reliability, security, and scalability, making it suitable for mission-critical applications.
  2. Client-Server: Easy to deploy, manage and maintain, and provides a centralized point of control.
  3. Cloud Computing: Cost-effective and scalable, with easy access to a wide range of resources and services.
  4. Mobile Computing: Allows users to access information and applications from anywhere, at any time.
  5. Grid Computing: Provides a way to harness the power of multiple computers for large-scale computations.
  6. Embedded Systems: Enable the integration of software into devices and products, making them smarter and more functional.

 

Disadvantages of different computing environments:

  1. Mainframe: High cost and complexity, with a significant learning curve for developers.
  2. Client-Server: Dependence on network connectivity, and potential security risks from centralized data storage.
  3. Cloud Computing: Dependence on network connectivity, and potential security and privacy concerns.
  4. Mobile Computing: Limited processing power and memory compared to other computing environments, and potential security risks.
  5. Grid Computing: Complexity in setting up and managing the grid infrastructure.
  6. Embedded Systems: Limited processing power and memory, and the need for specialized skills for software development

 

FREE AND OPEN-SOURCE OPERATING SYSTEMS

A Free and Open-Source Operating System is an OS whose source code is freely available for anyone to view, modify, distribute, and use. FOSS operating systems promote transparency, community development, and software freedom.

Key Characteristics of Free and Open-Source OS

1. Open Source Code

  • The source code is publicly available.
  • Anyone can study, modify, and improve the code.

2. Free to Use

  • Most FOSS OS are available free of cost.
  • You can install them on multiple machines without licensing restrictions.

3. Community-Driven Development

  • Developed and improved by global communities.
  • Bugs, security issues, and new features are contributed by developers worldwide.

4. High Security

  • Open code = continuous auditing.
  • Vulnerabilities are identified and fixed quickly.

5. Customization

  • Users can tailor the OS based on their needs.
  • Useful for servers, embedded systems, and research.

6. Stability and Reliability

  • Many FOSS OS (like Linux distributions) offer long-term stability.
  • Widely used in servers, supercomputers, cloud, networking devices.

 

Examples of Free and Open-Source Operating Systems

Linux Distributions

Linux is the most widely used open-source OS kernel. Different organizations package it into “distributions”.

1. Ubuntu

  • User-friendly
  • Best for beginners
  • Popular for desktops and servers

2. Fedora

  • Cutting-edge technologies
  • Sponsored by Red Hat
  • Used for development and research

3. Debian

  • Very stable
  • Widely used in servers
  • Basis for Ubuntu

4. CentOS / Rocky Linux / AlmaLinux

  • Enterprise-level stability
  • Used in web servers, databases, hosting services

5. Linux Mint

  • Easy for Windows users
  • Smooth and simple UI

6. Arch Linux

  • Lightweight and customizable
  • Rolling release model
  • Preferred by advanced users

 

 

 

SYSTEM STRUCTURES: OPERATING SYSTEM SERVICES

An Operating System provides services to both the users and to the programs.

  • It provides programs an environment to execute.
  • It provides users the services to execute the programs in a convenient manner.

Following are a few common services provided by an operating system −

  • Program execution
  • I/O operations
  • File System manipulation
  • Communication
  • Error Detection
  • Resource Allocation
  • Protection

 

Program execution:

Operating systems handle many kinds of activities from user programs to system programs like printer spooler, name servers, file server, etc. Each of these activities is encapsulated as a process.

A process includes the complete execution context (code to execute, data to manipulate, registers, OS resources in use). Following are the major activities of an operating system with respect to program management −

  • Loads a program into memory.
  • Executes the program.
  • Handles program's execution.
  • Provides a mechanism for process synchronization.
  • Provides a mechanism for process communication.
  • Provides a mechanism for deadlock handling.

 

 

I/O Operation

An I/O subsystem comprises of I/O devices and their corresponding driver software. Drivers hide the peculiarities of specific hardware devices from the users.

An Operating System manages the communication between user and device drivers.

  • I/O operation means read or write operation with any file or any specific I/O device.
  • Operating system provides the access to the required I/O device when required.

 

File system manipulation

A file represents a collection of related information. Computers can store files on the disk (secondary storage), for long-term storage purpose.

Examples of storage media include magnetic tape, magnetic disk and optical disk drives like CD, DVD. Each of these media has its own properties like speed, capacity, data transfer rate and data access methods.

A file system is normally organized into directories for easy navigation and usage. These directories may contain files and other directions. Following are the major activities of an operating system with respect to file management −

  • Program needs to read a file or write a file.
  • The operating system gives the permission to the program for operation on file.
  • Permission varies from read-only, read-write, denied and so on.
  • Operating System provides an interface to the user to create/delete files.
  • Operating System provides an interface to the user to create/delete directories.
  • Operating System provides an interface to create the backup of file system.

 

Communication

In case of distributed systems which are a collection of processors that do not share memory, peripheral devices, or a clock, the operating system manages communications between all the processes. Multiple processes communicate with one another through communication lines in the network.

 

The OS handles routing and connection strategies, and the problems of contention and security.

 

Following are the major activities of an operating system with respect to communication −

  • Two processes often require data to be transferred between them
  • Both the processes can be on one computer or on different computers, but are connected through a computer network.
  • Communication may be implemented by two methods, either by Shared Memory or by Message Passing.

 

Error handling

Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the memory hardware. Following are the major activities of an operating system with respect to error handling −

  • The OS constantly checks for possible errors.
  • The OS takes an appropriate action to ensure correct and consistent computing.

 

Resource Management

In case of multi-user or multi-tasking environment, resources such as main memory, CPU cycles and files storage are to be allocated to each user or job. Following are the major activities of an operating system with respect to resource management −

  • The OS manages all kinds of resources using schedulers.
  • CPU scheduling algorithms are used for better utilization of CPU.

Protection

Considering a computer system having multiple users and concurrent execution of multiple processes, the various processes must be protected from each other's activities.

Protection refers to a mechanism or a way to control the access of programs, processes, or users to the resources defined by a computer system. Following are the major activities of an operating system with respect to protection −

  • The OS ensures that all access to system resources is controlled.
  • The OS ensures that external I/O devices are protected from invalid access attempts.
  • The OS provides authentication features for each user by means of passwords.

 

User and Operating-System Interface:

An Operating System (OS) provides an interface that allows users and programs to interact with the computer hardware. This interface ensures smooth communication between the user and the machine.

What is a User–OS Interface?

A User and Operating-System Interface refers to the methods, tools, and mechanisms through which a user interacts with the OS and the OS communicates with user programs.

It allows users to:

  • Give commands
  • Run programs
  • Manage files
  • Use hardware devices
  • View system information

 

Types of User Interfaces in Operating Systems

1.       Command-Line Interface (CLI)

  • Text-based interface.
  • User types commands to interact with the system.
  • Powerful and flexible for advanced users.
  • Requires knowledge of commands.

Examples:

  • Linux/Unix Shell (bash, sh, zsh)
  • Windows Command Prompt
  • PowerShell

Advantages:

  • Fast execution
  • Low resource usage
  • Suitable for automation (scripts)

Disadvantages:

  • Hard for beginners
  • Requires memorizing commands

 

2.      Graphical User Interface (GUI)

  • Visual interface with windows, icons, menus, buttons.
  • User-friendly and easy to learn.
  • Uses pointing devices like mouse or touch.

Examples:

  • Windows OS (Desktop GUI)
  • macOS
  • Ubuntu GNOME/KDE

Advantages:

  • Easy navigation
  • Attractive design
  • Suitable for general users

Disadvantages:

  • Requires more RAM/CPU
  • Slower than CLI for some tasks

 

3.      Touchscreen Interface

  • Used in smartphones, tablets, kiosks.
  • Based on gesture inputs: tap, swipe, pinch.

Examples:

  • Android OS
  • iOS
  • Windows Touch

 

4.      Voice User Interface (VUI)

  • Interact with the OS using voice commands.

Examples:

  • Siri (iOS/macOS)
  • Cortana (Windows)
  • Google Assistant (Android)

 

 

OPERATING SYSTEM INTERFACE FOR PROGRAMS

Applications also interact with the OS through:

1.       System Calls (OS-Program Interface)

System calls are functions provided by the OS that allow programs to request services from the kernel.

Types of system calls:

  1. Process control
  2. File management
  3. Device management
  4. Information maintenance
  5. Communication

Examples:
fork(), exec(), open(), read(), write(), close()

 

2.      Application Programming Interface (API)

  • High-level library functions that make system calls easier.
  • Developers use APIs to write programs without dealing with kernel-level complexity.

Examples:

  • WinAPI (Windows)
  • POSIX API (Unix/Linux)
  • Java API
  • Android API

 

3.      User Programs

User applications rely on OS services such as:

  • File I/O
  • Memory allocation
  • Network access
  • Interface rendering

 

Kernel vs. Shell (User–OS Interaction Components)

1. Kernel

  • Core part of OS.
  • Manages hardware, memory, processes.
  • Runs in privileged mode.

2. Shell

  • Interface between user and kernel.
  • Accepts commands and passes them to kernel.
  • Can be GUI (Windows Explorer) or CLI (bash shell).

 

4.      Command Interpreter (Shell)

The shell executes user commands by:

  • Reading commands
  • Interpreting them
  • Requesting kernel services
  • Displaying results

Examples: Bash, Zsh, PowerShell.

 

5.      Role of Operating System in User Interface

OS handles:

  • User login/logout
  • Desktop display
  • File explorer interface
  • System settings
  • Notifications
  • Keyboard/mouse input
  • Touch and voice input processing

 

 

 

 

SYSTEM CALLS

A system call is an interface between a program running in user space and the operating system (OS). Application programs use system calls to request services and functionalities from the OS's kernel. This mechanism allows the program to call for a service, like reading from a file, without accessing system resources directly.

When a program invokes a system call, the execution context switches from user to kernel mode, allowing the system to access hardware and perform the required operations safely. After the operation is completed, the control returns to user mode, and the program continues its execution.

This layered approach facilitated by system calls:

  • Ensures that hardware resources are isolated from user space processes.
  • Prevents direct access to the kernel or hardware memory.
  • Allows application code to run across different hardware architectures

 

How Do System Calls Work?

This high-level overview explains how system calls work:

1. System Call Request. The application requests a system call by invoking its corresponding function. For instance, the program might use the read() function to read data from a file.

2. Context Switch to Kernel Space. A software interrupt or special instruction is used to trigger a context switch and transition from the user mode to the kernel mode.

3. System Call Identified. The system uses an index to identify the system call and address the corresponding kernel function.

4. Kernel Function Executed. The kernel function corresponding to the system call is executed. For example, reading data from a file.

 


5. System Prepares Return Values. After the kernel function completes its operation, any return values or results are prepared for the user application.

6. Context Switch to User Space. The execution context is switched back from kernel mode to user mode.

7. Resume Application. The application resumes its execution from where it left off, now with the results or effects of the system call.

The following features are indicative of system calls:

  • Security. System calls ensure that user-space applications cannot harm the system or interfere with other processes.
  • Abstraction. For example, programs do not need to know the specifics of network hardware configurations to send data over the internet or disk operations to read a file, as the OS handles these tasks.
  • Access Control. System calls enforce security measures by checking whether a program has the appropriate permissions to access resources.
  • Consistency. Interactions between the OS and program remain consistent, regardless of the underlying hardware configuration. The same program can run on different hardware if the operating system supports it.
  • Synchronous Operation. Many system calls operate synchronously, blocking the calling process until the operation is complete. However, there are also asynchronous system calls that allow processes to continue execution without waiting.
  • Process Control. System calls facilitate stable process management and multitasking through process creation, termination, scheduling, and synchronization mechanisms.
  • File Management. System calls support file operations such as reading, writing, opening, and closing files.
  • Device Management. System calls enable processes to request device access, perform read or write operations on these devices, and release them afterward.
  • Resource Management. System calls help allocate and deallocate resources like memory, CPU time, and I/O devices.
  • Maintenance. System calls are used to obtain or configure system information, such as the date and time or process status.
  • Communication. System calls allow processes to communicate with each other and synchronize their actions.
  • Error Handling. When a system call cannot be completed, it returns an error code that the calling program can process.

 

Types of System Calls,

System calls are divided into five major categories based on the services they provide.

 

1. Process Control System Calls

Used to create, run, and manage processes.

Purpose

  • Create & terminate processes
  • Change process state
  • Load programs
  • Manage process attributes

Examples

  • fork() – Create a new process
  • exec() / execve() – Execute a new program
  • exit() – Terminate the process
  • wait() – Wait for a child process
  • getpid() – Get process ID
  • kill() – Send signals to processes

 

2. File Management System Calls

Used to create, read, write, and manipulate files.

Purpose

  • Manage files and directories
  • Access file attributes
  • Read/write data

Examples

  • open() – Open a file
  • read() – Read data
  • write() – Write data
  • close() – Close a file
  • lseek() – Change file pointer location
  • stat() – File information
  • unlink() – Delete a file
  • mkdir() / rmdir() – Create/remove directory

 

 3. Device Management System Calls

Allows programs to request and interact with I/O devices.

Purpose

  • Request or release devices
  • Perform device-specific operations
  • Control hardware behavior

Examples

  • ioctl() – Device-specific operations
  • read() – Read from a device
  • write() – Write to a device
  • open() / close() – Open/close device files

 

4. Information Maintenance System Calls

Used to get or set system information.

Purpose

  • Retrieve device, file, system, or user info
  • Manage time/date
  • Modify attributes

Examples

  • gettimeofday() – Get time/date
  • settimeofday() – Set time/date
  • uname() – System name & version
  • getuid() – Get user ID
  • setuid() – Set user ID
  • getgid() – Get group ID
  • getrlimit() – Get system resource limits

 

5. Communication (IPC) System Calls

Used for data exchange between processes or computers.

Purpose

  • Inter-process communication
  • Synchronization
  • Network communication

Examples

  • pipe() – Create pipe for communication
  • shmget() – Create shared memory
  • shmat(), shmdt() – Attach/detach shared memory
  • msgsnd() / msgrcv() – Message queues
  • socket() – Create network socket
  • bind() – Bind address to socket
  • listen() / accept() – Server communication
  • send() / recv() – Send/receive data

 

 

SYSTEM PROGRAMS

System programs are utility programs that provide a convenient environment for program development, execution, and system management.

They act as a bridge between the user and the OS, making the system easy to use.

 

Major Categories of System Programs

1. File Management Programs

  • Manage files and directories.
    Examples: File Explorer, ls, cp, mv, rm.

2. Status Information Programs

  • Display system information.
    Examples: top, ps, Task Manager.

3. Programming Tools

  • Help developers create and debug programs.
    Examples: Editors (VS Code), compilers (gcc), linkers, debuggers.

4. Communication Programs

  • Enable communication between users/systems.
    Examples:
    ssh, email clients, remote login tools.

5. Background Services (Daemons)

  • Perform background tasks automatically.

Examples:

  • cron jobs
  • System logging service
  • Print spoolers

 

6. File Modification Programs

  • Edit or modify files.
    Examples: Notepad, nano, vim.

7. System Utilities

  • Provide system-level services such as backup, compression, antivirus.
    Examples: Disk Cleanup, WinZip, backup tools.

 

OPERATING SYSTEM DESIGN AND IMPLEMENTATION

 

Design and Implementation of OS not “solvable”, but some approaches have proven successful Internal structure of different Operating Systems can vary widely

Start by defining goals and specifications Affected by choice of hardware,

 

Type of system User goals and System goals

 

User goals – operating system should be convenient to use, easy to learn, reliable, safe, and fast System goals – operating system should be easy to design, implement, and maintain, as well as flexible, reliable, error-free, and efficient

 

Important principle to separate

Policy: What will be done?

Mechanism: How to do it?

Mechanisms determine how to do something; policies decide what will be done

 

The separation of policy from mechanism is a very important principle, it allows maximum flexibility if policy decisions are to be changed later

 

Simple Structure

 

MS-DOS – written to provide the most functionality in the least space Not divided into modules

Although MS-DOS has some structure, its interfaces and levels of Functionality are not well separated

 

·         MS-DOS (which stands for Microsoft Disc Operating Systems) is a Microsoft developed OS. This came out initially in 1981 and quickly became the preferred OS over IBM-compatible desktop computers in the decades that followed.

·         Microsoft's DOS is an interface for the command line (CLI) OS, which means it lacks the visual user interface (GUI) found in modern OSes like Microsoft Windows or Mac OS. Clients communicate with the OS instead by entering instructions into an administrative prompt

·         MS-DOS was intended to serve as a simple and efficient computer operating system capable of running on cheap-powered hardware. It included basic features like managing files, disc presentation, and disc services. Microsoft's DOS transformed over the years to accommodate advanced functions such as social media, handling memory, and performing multiple tasks.

·         The MS-DOS eventually got supplanted by Windows from Microsoft, which included a graphical user interface and enhanced features. MS-DOS, on the other hand, is a significant component of calculating the past and continues to be utilized in specialized tasks and systems that are embedded

 

 

MS-DOS Architecture

 


  The architecture of MS-DOS (Microsoft Disk Operating System) includes the following components

  • Application Program? Application programs refer to the software applications that users interact with to perform specific tasks. These programs could include word processors, spreadsheets, games, or any other software designed to run on MS-DOS. Application programs are written by software developers using programming languages compatible with MS-DOS.
  • Resident System Programs? Resident system programs are essential components of the operating system that remain in memory throughout the computer's operation. These programs provide various system services and utilities required for the functioning of MS-DOS. Examples of resident system programs in MS-DOS include the command interpreter (COMMAND.COM), which handles user commands and runs programs, and the disk caching system, which improves disk read/write performance.
  • MS-DOS Device Drivers? MS-DOS device drivers are software modules that enable communication between the operating system and specific hardware devices connected to the computer. These drivers provide an interface for MS-DOS to access and control devices such as printers, keyboards, mice, disk drives, and display adapters. Device drivers allow MS-DOS to manage the hardware resources efficiently and provide a standardized way for applications to interact with hardware devices.
  • ROM BIOS Device Drivers? ROM BIOS (Read-Only Memory Basic Input/Output System) device drivers are low-level software modules stored in the computer's firmware. These drivers provide the necessary instructions for MS-DOS to communicate with hardware devices during the boot process. ROM BIOS device drivers initialize hardware components such as the keyboard, display, disk drives, and other peripherals, enabling MS-DOS to interact with them from the moment the computer starts up

 

Advantages:

  • Efficient use of system resources 
  • Simple and intuitive command-line interface 
  • The wide availability of software 
  • Compatibility with a wide range of hardware 
  • Stability 

 

Disadvantages

  • Limited multitasking support 
  • No graphical user interface(GUI) 
  • Lack of built-in networking support 
  • Lack of plug-and-play support 
  • Vulnerabilities to security threats 

 

 

OPERATING SYSTEM STRUCTURE

 

The operating system can be implemented with the help of various structures. The structure of the OS depends mainly on how the various standard components of the operating system are interconnected and merge into the kernel. This article discusses a variety of operating system implementation structures and explains how and why they function.

 

 

What is a System Structure for an Operating System?

A system structure for an operating system is like the blueprint of how an OS is organized and how its different parts interact with each other. Because operating systems have complex structures, we want a structure that is easy to understand so that we can adapt an operating system to meet our specific needs.

Similar to how we break down larger problems into smaller, more manageable sub problems, building an operating system in pieces is simpler. The operating system is a component of every segment. The strategy for integrating different operating system components within the kernel can be thought of as an operating system structure.

 

Types of Operating Systems Structures

 

Depending on this, we have the following structures in the operating system:


  • Simple Structure
  • Layered Structure
  • Modular Structure
  • Virtual Machines
  • Monolithic Structure
  • Micro-Kernel Structure
  • Hybrid-Kernel Structure
  • Exo-Kernel Structure

 

Simple Structure

Simple structure operating systems do not have well-defined structures and are small, simple and limited. The interfaces and levels of functionality are not well separated. MS-DOS is an example of such an operating system. In MS-DOS, application programs are able to access the basic I/O routines. These types of operating systems cause the entire system to crash if one of the user programs fails.

 

 


 

Advantages of Simple Structure

  • Better Performance: Due to minimal abstraction and fewer interfaces between hardware and software, the OS tends to be faster.
  • Ease of Development: Kernel development is simpler as everything is tightly integrated. Developers can directly interact with hardware and internal functions without needing to coordinate across modules.
  • Low Overhead: Simple structures avoid the overhead caused by inter-module communication. Memory usage is optimized due to minimal modularization.
  • Faster Debugging (in some cases): With all parts tightly coupled, developers can trace bugs more directly—though this can be a double-edged sword.
  • Ideal for Small Systems: Suitable for embedded systems or small-scale environments where minimal functionality is required.

Disadvantages of Simple Structure

  • Lack of Modularity: No clear separation between functionalities (like file system, memory management, etc.). A change in one part may affect others, making updates and maintenance risky.
  • Poor Maintainability: As the OS grows, maintaining the code becomes increasingly difficult. It is harder to isolate faults or enhance specific components.
  • No Data Hiding: All parts of the kernel can access each other’s data, violating principles of encapsulation. This increases the chance of bugs and unintended side-effects.
  • Difficult to Scale: Cannot be easily extended or adapted for more complex hardware or software requirements.
  • Security Risks: With no strict boundaries or protections, bugs or vulnerabilities in one component may compromise the entire system.

 

 

 Layered Structure:

·         An OS can be broken into pieces and retain much more control over the system. In Layered structure, the OS is broken into a number of layers (levels). The bottom layer (layer 0) is the hardware and the topmost layer (layer N) is the user interface.

·         These layers are so designed that each layer uses the functions of the lower-level layers. This simplifies the debugging process, if lower-level layers are debugged and an error occurs during debugging, then the error must be on that layer only, as the lower-level layers have already been debugged. 

·         The main disadvantage of this structure is that at each layer, the data needs to be modified and passed on which adds overhead to the system.

·         Moreover, careful planning of the layers is necessary, as a layer can use only lower-level layers. UNIX is an example of this structure

 

 


 

 

Advantages of Layered Structure


  • Modularity
  • Ease of Enhancement
  • Simplified Debugging and Testing: 
  • Improved Maintainability: 

  • Data Hiding and Encapsulation
  • Better Organization of Code

 

Disadvantages of Layered Structure


  • Performance Overhead
  • Rigid Structure
  • Complex Design Requirements
  • Dependency Management

  • Increased Code Duplication (in some cases): If layers don’t share utilities efficiently, similar operations might be duplicated across layers, increasing codebase size

 

Modular Structure

It is considered as the best approach for an OS. It involves designing of a modular kernel. The kernel has only a set of core components and other services are added as dynamically loadable modules to the kernel either during runtime or boot time. It resembles layered structure due to the fact that each kernel has defined and protected interfaces, but it is more flexible than a layered structure as a module can call any other module. For example Solaris OS is organized as shown in the figure.

 


 

 

Virtual Machines (VMs)

 

Based on our needs, a virtual machine abstracts the hardware of our personal computer, including the CPU, disc drives, RAM and NIC (Network Interface Card), into a variety of different execution contexts, giving us the impression that each execution environment is a different computer. An illustration of it is a virtual box. An operating system enables us to run multiple processes concurrently while making it appear as though each one is using a different processor and virtual memory by using CPU scheduling and virtual memory techniques.

 

 


 

 The fundamental issue with the virtual machine technique is disc systems. Let's say the physical machine only has three disc drives, but it needs to host seven virtual machines. The program that creates virtual machines would need a significant amount of disc space in order to provide virtual memory and spooling, so it should be clear that it is impossible to assign a disc drive to every virtual machine. The answer is to make virtual discs available.

 

Advantages of Virtual Machines (VMs)

·         Hardware Abstraction

·         Efficient Resource Utilization

·         Isolation and Security

·         Flexibility and Portability

·         Support for Legacy Software

·         Snapshots and Rollbacks

·         Simplified Deployment

·          

Disadvantages of Virtual Machines (VMs)

·         Performance Overhead

·         Disk and Memory Limitations

·         Complex Resource Management

·         Requires Powerful Host System

·         Security Risks in Mis-configured Systems

·         Limited Access to Physical Hardware

·         Licensing and Management Overhead

 

 

Monolithic Structure

monolithic structure is a type of operating system architecture where the entire operating system is implemented as a single large process in kernel mode. Essential operating system services, such as process management, memory management, file systems and device drivers, are combined into a single code block

 

 

Micro-Kernel Structure

Micro-Kernel structure designs the operating system by removing all non-essential components from the kernel and implementing them as system and user programs. This results in a smaller kernel called the micro-kernel. Advantages of this structure are that all new services need to be added to user space and does not require the kernel to be modified. Thus it is more secure and reliable as if a service fails, then rest of the operating system remains untouched. Mac OS is an example of this type of OS. 

 

 

Hybrid-Kernel Structure

Hybrid-Kernel structure is nothing but just a combination of both monolithic-kernel structure and micro-kernel structure. Basically, it combines properties of both monolithic and micro-kernel and make a more advance and helpful approach. It implement speed and design of monolithic and modularity and stability of micro-kernel structure.

 

 

Exo-Kernel Structure

Exokernel is an operating system developed at MIT to provide application-level management of hardware resources. By separating resource management from protection, the exokernel architecture aims to enable application-specific customization. Due to its limited operability, exokernel size typically tends to be minimal. The OS will always have an impact on the functionality, performance and scope of the apps that are developed on it because it sits in between the software and the hardware. The exokernel operating system makes an attempt to address this problem by rejecting the notion that an operating system must provide abstractions upon which to base applications. The objective is to limit developers use of abstractions as little as possible while still giving them freedom.

 

BUILDING AND BOOTING AN OPERATING SYSTEM

 

Building an Operating System:

Building an OS means creating the components required for running applications and managing hardware.
The OS is usually built using C, C++, and Assembly.

 

1.Components Involved in Building an OS

  1. Bootloader – small program that loads the OS
  2. Kernel – core part of OS
  3. System Libraries – provide OS functions (e.g., libc)
  4. Device Drivers – interact with hardware
  5. File System – stores data
  6. User Interface – shell or GUI

 

2. Building Process (Steps)

 

Step 1: Source Code

OS developers write:

  • kernel code
  • drivers
  • file system code
  • scheduler
  • memory manager

Step 2: Compilation

The OS source code is compiled using:

  • Compiler (GCC)
  • Assembler

Output: object files (.o)

Step 3: Linking

All object files are linked into one kernel binary
Example: vmlinuz in Linux.

Step 4: Create Bootable Image

Tools pack kernel + bootloader into:

  • ISO file
  • Bootable USB image

Step 5: Install on disk

The OS is stored in the boot partition.

 

OS Build Process

 


 

Booting an Operating System

Booting is the process of loading the operating system into memory after the system is powered on.

Booting Steps (Simple Explanation)

1. Power On

Power button → electrical signals activate CPU, RAM, motherboard.

2. BIOS/UEFI Initialization

BIOS/UEFI performs:

·         POST (Power-On Self-Test)

·         Checks RAM, keyboard, CPU

·         Selects boot device (HDD/SSD/USB)

3. Load Bootloader

BIOS/UEFI loads the Bootloader from the boot sector.

Bootloaders:

·         GRUB (Linux)

·         NTLDR/Bootmgr (Windows)

·         LILO (old Linux)

4. Bootloader Loads Kernel

Bootloader loads the OS kernel into memory.

Example:
vmlinuz (Linux kernel)

5. Kernel Initialization

Kernel performs:

·         Set up memory management

·         Initialize CPU & process scheduler

·         Load device drivers

6. Start System Services

System manager starts:

·         systemd (Linux)

·         Init services

·         Windows Service Manager

7. User Interface Loads

Finally:

·         Login screen

·         GUI (Windows Desktop / GNOME / KDE)

·         Shell (Linux terminal)

 

 


OPERATING SYSTEM DEBUGGING

 

Operating system (OS) debugging is the process of finding and resolving errors (bugs) or performance bottlenecks within the OS kernel, device drivers, and system components. This differs from debugging a normal application due to the low-level nature, the potential for total system crashes, and non-deterministic behavior. 

 

Key Concepts

  • Kernel vs. User Mode Debugging: Applications typically run in user mode, within their own isolated memory space. The core OS and drivers run in kernel mode, with direct access to all system hardware and memory. Kernel-mode bugs can crash the entire system (a "kernel panic" in Linux or a "Stop error" in Windows).
  • Host and Target Systems: OS debugging often uses two machines: a host system runs the debugger software, and a target system runs the OS being debugged. They are typically connected via a serial port or network (e.g., using KDNET for Windows).
  • Virtual Machines (VMs): Using VMs (like QEMU, Bochs, or VMware) is a common and convenient approach, where the host machine runs the debugger and the guest VM runs the target OS, often on the same physical machine.
  • Non-intrusive Debugging: Traditional debuggers often halt the entire system's execution at a breakpoint, which can interfere with the timing of events (Heisenbugs). Advanced tools and virtual machine technologies, like "time-traveling virtual machines," allow for non-intrusive monitoring and even reverse execution to trace the cause of a bug without disrupting the system's real-time performance. 

 

 

Techniques and Tools

Several methods are used for OS debugging, depending on the stage of development and the nature of the problem: 

  • Logging and Trace Listing: The most basic method involves writing diagnostic messages or system events to a log file (e.g., using printk() in Linux or event logs in Windows). These logs can be analyzed later (post-mortem analysis) to understand system behavior and pinpoint anomalies.
  • Crash Dumps/Core Dumps: When a kernel crash occurs, the OS can save the entire contents of physical memory (a crash dump) to a file. These dump files contain the system state at the time of failure and are analyzed offline using specialized tools (like WinDbg or crash utility in Linux).
  • Kernel Debuggers: These are specialized tools (e.g., GDB, KGDB, WinDbg) that allow developers to step through kernel code, set breakpoints, inspect memory, and examine the call stack. They require specific setup (e.g., compiling the kernel with debug flags like -g).
  • Performance Tuning Tools/Profilers: If performance is an issue, tools like Windows Task Manager, DTrace, or code profilers are used to identify processing bottlenecks, analyze CPU and memory usage, and monitor I/O operations.
  • Assertions and Sanity Checks: Experienced programmers embed self-checking code into the OS that stops execution or prints an error if a violation of an assumption occurs (e.g., a null pointer dereference). 

 

 

 

 

 

***********End of UNIT - I***********

No comments:

Post a Comment

OS UNIT-II

  UNIT-II   Processes: Process Concept, Process scheduling, Operations on processes, Inter-process communication. Threads and Concurrenc...