Unit - 1
Introduction
1. Concept of Operating Systems
Software and Hardware Definitions
- Program: A program is defined as a collection of code or instructions.
- Software: Software is a collection of programs.
- Hardware: This refers to the physical devices that make up a computer system.
- Examples of Hardware: Key components include the Processor, RAM, Hard disk, and various devices.
Types of Software
Software is categorized into three primary types:
1. System Software
- This software is used to perform all types of system-level tasks for the computer.
- Examples: Operating systems, Compilers, Interpreters, Linkers, and Loaders.
2. Utility Software
- This software provides additional functionality or "meaning" to the computer system.
- Examples: Calculators, MS-Paint, Web Browsers, Notepads, and Media Players.
3. Application Software
- These are created by users using different high-level languages and database systems for specific purposes.
- Examples: Library Management Systems, Banking Software, and Ticket Reservation systems.
Definition of Operating System
An Operating System (OS) can be defined in two primary ways:
- As a Manager: It is a collection of system software that manages computer hardware resources and provides common services for computer programs.
- As an Interface: It acts as an intermediary or interface between a user of a computer and the computer hardware.
- Users and processes access the computer's physical resources (Hardware) exclusively through the Operating System.
Operating System Goals
The primary objectives of an operating system include:
- User Convenience: To simplify the execution of user programs and make solving user problems easier.
- Efficiency: To ensure that the computer hardware is used efficiently.
- Resource Sharing: To allow the sharing of both hardware and software resources among different users or programs.
- Portability: To make application software portable and flexible.
- Security: To provide isolation, security, and protection among various user programs.
- Reliability: To improve overall system reliability through features like error confinement, fault tolerance, and reconfiguration.
2. Generations of Operating Systems
The history of operating systems is divided into four distinct generations.
First Generation (1945–1955)
Vacuum Tubes and Plugboards * Digital computers were not constructed until World War II.
- Early calculating engines used mechanical relays, which were very slow.
- Mechanical relays were eventually replaced by vacuum tubes.
- These machines were enormous in size but remained very slow in operation.
Machine Language and Numerical Calculations * There were no operating systems during this period, and programming languages were unknown.
- All programming was performed directly in machine language.
- Problems solved were almost exclusively simple numerical calculations.
- In the 1950s, punch cards were introduced, allowing programs to be read into the system instead of using plugboards.
Second Generation (1955–1965)
Transistors and Batch Systems * The introduction of transistors allowed for the manufacturing of computers that could be sold to customers.
- To reduce wasted time in computer operations, the Batch System was introduced.
Mainframes and Magnetic Tape * These computers were known as mainframes and were kept in locked, air-conditioned rooms operated by specialized staff.
- In a batch system, a tray of jobs was collected in an input room and read onto magnetic tape.
Third Generation (1965–1980)
Integrated Circuits and Multiprogramming * This generation utilized Integrated Circuits (ICs), providing major price and performance advantages.
- Operating systems introduced Multiprogramming, which ensured the processor did not remain idle while a job completed I/O operations.
- When one job was waiting, another job was scheduled on the processor so time was not wasted.
IBM System/360 * IBM combined scientific and commercial computer systems into the System/360.
Fourth Generation (1980–Present)
Personal Computers and LSI Circuits * The development of Large-Scale Integrated (LSI) circuits—chips containing thousands of transistors on a square centimeter of silicon—made Personal Computers easy to create.
Network and Distributed Operating Systems * The advent of PCs led to the growth of networks, creating Network Operating Systems and Distributed Operating Systems.
- In a network OS, users are aware of the network and can log in to remote machines or copy files between them.
Examples: Windows, Mac OS, and Linux * Microsoft Windows: Created in the mid-1980s. Versions include Windows Vista, 7, 8, and 10. It is the most popular OS as it comes pre-loaded on most PCs.
- Mac OS: A line of operating systems created by Apple that comes preloaded on Macintosh computers. Versions include Lion, Mountain Lion, Mavericks, Yosemite, and El Capitan.
- Linux: A family of open-source operating systems that can be modified and distributed by anyone. It is free and available in many different distributions.
Mobile Device Operating Systems * Mobile devices (smartphones, tablets) run operating systems specifically designed for them, as they differ from desktop/laptop hardware.
- Examples: Apple iOS and Google Android.
3. Types of Operating Systems
Simple Batch System
- Lack of Interaction: There is no direct interaction between the user and the computer.
- Job Submission: The user submits a job, written on cards or tape, to a computer operator.
- Batch Processing: The operator places a batch of several jobs on an input device for processing.
- Advantages: It increases performance as the next job starts immediately after the previous one finishes, making it suitable for large jobs with little interaction.
- Disadvantages: There is zero interaction and no mechanism to prioritize processes.
Multiprogramming Batch System
- CPU Multiplexing: Several jobs are kept in main memory at the same time, and the CPU is multiplexed among them.
- CPU Utilization: This system increases CPU utilization because the CPU is always executing some program instead of waiting for I/O operations.
- Memory Layout: Multiple jobs are loaded into main memory, and one is selected from the pool for execution.
- Job Scheduling: If a program in progress requires I/O service, control of the CPU is given to the next job in main memory.
- Efficiency Comparison: Multiprogramming significantly improves throughput (e.g., vs in uniprogramming) and reduces mean response time.
Effects of Multiprogramming (The Comparison)
The following table demonstrates why multiprogramming is more efficient than uniprogramming:
| Metric | Uniprogramming | Multiprogramming |
|---|---|---|
| Processor use | 17% | 33% |
| Memory use | 30% | 67% |
| Disk use | 33% | 67% |
| Printer use | 33% | 67% |
| Elapsed time | 30 min. | 15 min. |
| Throughput rate | 6 jobs/hr | 12 jobs/hr |
| Mean response time | 18 min. | 10 min. |
Multitasking / Time-Sharing System (TSS)
- Interactive Jobs: TSS extends multiprogramming to handle multiple interactive jobs, providing the impression that the entire computer is dedicated to a single user.
- Time-Slices: Each user is given a specific time-slice for executing their job.
- Round-Robin Fashion: Processes are given equal amounts of CPU time one by one in a sequence.
- Context Switches: The system allows frequent context switches from one user to the next when a time-slice ends.
- Advantages: It provides quick response times and reduces CPU idle time.
Multiprocessor / Parallel System
- Tightly Coupled Systems: These systems feature more than one CPU working in close communication, sharing memory, I/O devices, buses, and power supplies.
- Shared Memory: Communication between processors usually takes place through shared memory.
- Computing Power: It delivers higher computing power and speed under a single operating system.
- Reliability: Failure of one processor will not stop the system; it continues to function with the remaining processors.
- Economy: It is cheaper to buy one system with multiple CPUs than multiple systems with single CPUs.
Real-Time System
- Time Constraints: A Real-Time Operating System (RTOS) guarantees capabilities within specified time constraints.
- Hard Real-Time:
- It guarantees that critical operations complete on time.
- If the system fails to meet a deadline even once, the entire system is considered to have failed.
- Examples include defense applications and nuclear systems where missing deadlines creates hazards.
- Soft Real-Time:
- Critical tasks get priority, but there is no absolute assurance of completion within a defined time.
- Failing a deadline does not mean the system has failed, and results are still useful.
- Examples include audio-video streaming.
Distributed System
- Loosely Coupled Systems: Each processor has its own local memory, and they do not share a clock.
- Load Sharing: Computation is distributed among several physical processors to speed up processing and shorten response times.
- Communication Networks: Processors communicate via various lines such as high-speed buses or telephone lines using a protocol.
- Advantages: Includes resource sharing, incremental growth by adding resources, and higher reliability due to tolerance against failure.
4. Operating System Services
The operating system provides an environment for the execution of programs and services to the users of those programs.
User Interface (UI)
- Almost all operating systems have a user interface.
- Command-Line Interface (CLI): Uses text commands and a method for entering them.
- Graphics User Interface (GUI): A window system with a pointing device to direct I/O, choose from menus, and make selections.
- Batch Interface: Commands and directives to control those commands are entered into files, and those files are executed.
Program Execution
- The system must be able to load a program into memory and run that program.
- It must be able to end execution, either normally or abnormally (indicating an error).
I/O Operations
- A running program may require I/O, which may involve a file or an I/O device.
- Because user programs cannot execute I/O operations directly, the operating system must provide a means to do so.
File-System Manipulation
- Programs need to read and write files and directories.
- The OS handles creating and deleting files, searching them, listing file information, and permission management.
- It allows or denies access to files or directories based on file ownership.
Communications
- The OS facilitates the exchange of information between processes.
- Communications may occur between processes executing on the same computer or on different systems tied together by a network.
- This is implemented via shared memory or message passing.
Error Detection
- The OS needs to be constantly aware of possible errors.
- Errors may occur in the CPU and memory hardware, in I/O devices, or in user programs.
- For each type of error, the OS should take appropriate action to ensure correct and consistent computing.
Additional OS Services
These services exist for ensuring the efficient operation of the system itself rather than for the user.
Resource Allocation
- When multiple users or jobs are running concurrently, resources (such as CPU cycles, main memory, and file storage) must be allocated to each of them.
Accounting
- The OS keeps track of which users use how much and what kinds of computer resources.
- This data is used for accounting or usage statistics.
Protection and Security
- Protection: Involves ensuring that all access to system resources is controlled.
- Security: Defends the system against outsiders through user authentication (passwords) and protects external I/O devices from invalid access attempts.
- The system ensures that concurrent processes do not interfere with each other.
OS Management Components & Responsibilities
- Secondary Management: Used to back up main memory as primary storage is volatile and too small.
- Networking: Manages distributed systems where processors do not share memory or a clock.
- Protection System: Distinguishes between authorized and unauthorized usage and enforces access controls.
- Command-Interpreter System: Known as the Shell in UNIX, its function is to get and execute the next command statement.
5. System Calls
A system call is a request made by a user program in order to get the service of an operating system. When a program in user mode requires access to RAM or a hardware resource, it must ask the kernel to provide access via a system call.
User Mode vs. Kernel Mode
The CPU operates in two distinct modes to ensure system security and stability:
- Kernel Mode:
- This is a highly privileged and powerful mode.
- The code being executed can access any memory address and any hardware resource.
- If a program crashes in kernel mode, the entire system will be halted.
- User Mode:
- Programs do not have direct access to memory and hardware resources.
- If a program crashes in user mode, only that particular program is halted, leaving the rest of the system in a safe state.
- Most applications run in this mode to protect the system.
Process Management System Calls
These calls are used to control the lifecycle of processes.
- : Creates a child process that is identical to the parent.
- : Used by a parent process to wait for a child to terminate.
- : Replaces a process's core image with a new program.
- : Terminates process execution and returns a status code.
File Management System Calls
These calls handle individual file operations.
- : Opens a file for reading, writing, or both.
- : Closes an currently open file.
- : Reads data from a file into a buffer.
- : Writes data from a buffer into a file.
- : Moves the file pointer to a specific location.
- : Retrieves status information about a file.
Directory Management System Calls
These calls are used for managing the file system structure.
- : Creates a new directory.
- : Removes an empty directory.
- : Creates a new directory entry (name2) pointing to an existing file (name1).
- : Removes a directory entry.
- : Mounts a file system onto the directory tree.
- : Unmounts a previously mounted file system.
Miscellaneous System Calls
These calls handle various system tasks and file protections.
- : Changes the current working directory.
- : Changes a file's protection bits (permissions).
- : Sends a signal to a process, often used to terminate it.
- : Gets the elapsed time (in seconds) since January 1, 1970.
6. Structure of an Operating System
The structure of an OS determines how the various software components are organized and how they interact with the hardware.
Layered Structure
In the layered approach, the operating system is broken into a number of layers (levels).
- Hierarchy from Hardware to UI: The bottom layer (Layer 0) is the hardware, and the highest layer (Layer N) is the user interface.
- Encapsulation: Each layer uses functions and services of only lower-level layers.
- Simplicity and Debugging: A major advantage is the simplicity of construction and debugging. Since each layer only uses the layers below it, the first layer can be debugged without concern for the rest of the system.
- Disadvantages:
- Difficulty of Definition: It is challenging to appropriately define the various layers.
- Efficiency: This structure tends to be less efficient than other implementations because each layer adds overhead to system execution.
Monolithic Structure
The monolithic approach is the most common and simplest organization for an operating system.
- Kernel as One Large Program: The entire operating system runs as a single, large program in kernel mode.
- Shared Functionality: Functionality of the OS is activated with simple function calls within the kernel.
- Drivers: Device drivers are loaded directly into the running kernel and become an integral part of it.
- Performance: Because there is very little overhead in the communication between modules within the kernel, monolithic systems are often very fast.
- Components: A monolithic kernel typically manages processes, memory, files, and the device management infrastructure all within a single address space.
7. Microkernel Operating Systems
The microkernel approach structures the operating system by removing all non-essential components from the kernel.
Minimal Kernel and User-Level Programs
- Core Functionality: The microkernel offers only minimal process management, memory management, and a communications facility.
- External Services: All unnecessary parts of the kernel are removed and implemented instead as system-level and user-level programs.
- Operating Environment: These external services run in user mode rather than kernel mode.
Message Passing Communication
- Interaction Mechanism: Because the components are separated, communication between them is performed via message passing.
- Overhead: A significant disadvantage of this approach is poor performance caused by the increased system overhead required for message passing.
Extensibility and Reliability
- Advantages:
- Extensibility: The operating system can be easily extended since new services can be added as user-level programs without modifying the kernel.
- Kernel Maintenance: The kernel remains smaller, which means very few changes are required within it during updates.
- Security and Reliability: This structure offers more security and reliability because most services run in user space; if a service fails, it does not crash the entire kernel.
8. Concept of Virtual Machine
A Virtual Machine (VM) is a powerful concept in system architecture that allows for the creation of isolated execution environments on a single physical computer.
Hardware Abstraction and Illusion of Multiple Environments
- Hardware Abstraction: A virtual machine abstracts the physical hardware of a single computer, including the CPU, Memory, Disk drives, and Network Interface Cards.
- Creation of Illusion: It creates the illusion that each separate execution environment is running its own dedicated PC or environment.
- Execution Environments: This abstraction allows for several different execution environments to exist simultaneously on the same hardware.
Host and Guest Relationship
- Guest Machine: The Virtual Machine itself is often referred to as a "guest machine".
- Host Environment: The guest machine is created within another computing environment known as the "host".
- Resource Scaling: Multiple virtual machines can be present and operational within a single host at one time.