Module 1
Module 1
The purpose of an operating system is to provide an environment in which a user can execute
programs conveniently and efficiently.
An operating system is software that manages computer hardware and software. The hardware must
provide appropriate mechanisms to ensure the computer system's correct operation and prevent
user programs from interfering with the system's proper operation.
Operating system is a program running at all times on the computer (usually called the kernel), with
all else being application programs.
Concerned with assigning resources among programs, e.g., memory, processors, and input/output
devices.
Various tasks handled by OS are file management, task management, garbage management, memory
management, process management, disk management, I/O management, peripherals management,
etc.
Let us now discuss some of the important characteristic features of operating systems:
Device Management: The operating system keeps track of all the devices. So, it is also called the
input/output controller, which decides which process gets the device, when, and for how long.
File Management: It allocates and de-allocates the resources and decides who gets them.
Job Accounting: It keeps track of time and resources used by various jobs or users.
Error-detecting Aids: These contain methods that include the production of dump, error messages,
and other debugging and error-detecting methods.
Memory Management: It is responsible for managing the primary memory of a computer, including
what parts of it are in use by whom. It also checks how much is free or used and allocates the
process.
Processor Management: It allocates the processor to a process and then de-allocates it when it is no
longer required or the job is done.
Control on System Performance: It records the delays between the request for a service and the
system.
Security: Using passwords or some protection technique prevents unauthorized access to programs
and data.
Throughput: An OS should be constructed to give maximum throughput (Number of tasks per unit
time).
There are multiple types of operating systems, each having its unique features:
1. Windows OS: Easy to use for most users, Broad support from third-party applications, Frequent
updates and support.
Developer: Microsoft
Key Features: User-friendly interface, software compatibility, hardware support, Strong gaming
support.
2. macOS: Optimized for Apple hardware, Seamless experience across the Apple ecosystem, Superior
graphics and multimedia capabilities.
Developer: Apple.
Key Features: Sleek, intuitive user interface, strong integration with other Apple products, robust
security features, and high performance.
Typical Use Cases: Creative industries (design, video editing, music production), Personal computing,
and Professional environments.
3. Linux: Free to use and distribute, Strong community support, Suitable for servers and development
environments
Key Features: Open-source and highly customizable, robust security and stability, lightweight and can
run on older hardware, and a large selection of distributions (e.g., Ubuntu, Fedora, Debian).
Typical Use Cases: Servers and data centres, Development and programming, Personal computing for
tech enthusiasts.
4. Unix
Developer: Originally AT&T Bell Labs, various commercial and open-source versions available
Key Features: Multiuser and multitasking capabilities, Strong security and stability, Powerful
command-line interface, Portability across different hardware platforms
Advantages: Reliable and robust performance, Suitable for high-performance computing and servers,
Extensive support for networking
Typical Use Cases: Servers and workstations, Development environments, Research and academic
settings.
3. Operating system
4. Hardware
Every general-purpose computer consists of hardware, an operating system(s), system programs, and
application programs. The hardware consists of memory, CPU, ALU, I/O devices, peripheral devices, and
storage devices. The system program consists of compilers, loaders, editors, OS, etc.
Every computer must have an operating system to run other programs. The operating system coordinates
the use of the hardware among the various system programs and application programs for various users.
It simply provides an environment within which other programs can do useful work.
An OS is a package of some programs that runs on a computer machine, allowing it to perform efficiently.
It manages the simple tasks of recognizing input from the keyboard, managing files and directories on
disk, displaying output on the screen, and controlling peripheral devices.
It helps manage the data present in the device, i.e., Memory Management.
User Interaction: Batch processing; jobs were submitted on punch cards or magnetic tape.
Key Features:
User Interaction: Time-sharing allowed multiple users to interact with the system simultaneously.
Key Features:
User Interaction: Interactive user interfaces with command-line or graphical interfaces (GUI).
Key Features:
Key Features:
Key Features:
o AI and machine learning are incorporated into the OS for better user experiences.
This operating system processes jobs in batches without user interaction during execution. There is an
operator which takes similar jobs having the same requirements and groups them into batches. It is the
responsibility of the operator to sort jobs with similar needs. Batch Operating System is designed to manage
and execute many jobs efficiently by processing them in groups. Jobs are submitted in bulk, queued, and
executed sequentially. Applications or examples: Payroll processing, banking transactions, and large-scale
data jobs.
Advantages of Batch Operating System: Multiple users can share the batch systems.
CPU is not used efficiently. When the current process is doing IO, the CPU is free and could be utilized
by other processes waiting.
The other jobs will have to wait for an unknown time if any job fails.
In batch operating system, average response time increases as all processes are processed one by
one.
Large Jobs Cause Delays: If a batch contains a large job, then problems may occur because the
processing of all the subsequent jobs is delayed. This, therefore, slows down the overall system
performance.
There are five jobs J1, J2, J3, J4, and J5, present in the batch. If the execution time of J1 is very high, then the
other four jobs will never be executed, or they will have to wait for a very long time. Hence the other
processes get starved.
2. CPU Scheduling: The CPU switches between these jobs based on priority or availability of resources.
3. Resource Management: While one job waits for I/O operations (e.g., reading from a disk), the CPU
executes another job.
4. Concurrency: The operating system handles context switching, enabling multiple jobs to "progress"
simultaneously.
Advantages of Multiprogramming OS
o Throughout the system, it increased as the CPU always had one program to execute.
o Multiprogramming maximizes the utilization of resources like memory, I/O devices, and processing
power since more than one program can be kept alive at any time.
o Since several jobs are being processed in parallel, significantly more tasks could be completed within
a certain amount of time, thus enhancing the system's overall throughput.
o During times when a program is waiting for I/O operations, the processor does not go idle since it
jumps on to another task to continue processing.
o The system can support both short and long tasks to be executed in parallel, which makes for a more
dynamic and productive processing environment.
Disadvantages of Multiprogramming OS
o Multiprogramming systems provide an environment in which various systems resources are used
efficiently, but they do not provide any user interaction with the computer system.
o Multiple programs increase system complexity, as the operating system needs to manage multiple
processes, memory management, and scheduling.
o It requires more memory than less sophisticated operating systems because multiple programs run
simultaneously in memory.
o The operating system has to switch between the running processes continuously, and this leads to
scheduling overhead and reduces performance.
o As several concurrent operations access shared resources simultaneously, the system is likely to
experience deadlocks: two or more processes waiting for each other for further actions.
o Resource contention due to competition for scarce resources could degrade performance.
Multiprogramming extended the concept of multitasking operating systems, which enabled various programs
to run simultaneously. It allowed a user to do more than one task on the same system at a given time by
sharing various system resources like CPU time among different processes. This assures efficient CPU use
because it shifts between tasks quickly; hence, they seem to run parallel. Examples: Windows 10/11, Linux,
macOS, UNIX, Android/iOS.
There are multitasking systems in almost all personal computers where, for example, a user might run a web
browser, a music player, and a document editor simultaneously.
How Multitasking Works
1. Time-Slicing: The CPU allocates a small time slice to each task in a cyclic order.
2. Context Switching: When a task's allocated time expires, the system saves its state and switches to
another task.
3. Concurrency: Multiple tasks progress simultaneously, as the CPU rapidly switches between them.
4. Resource Sharing: System resources (e.g., memory, CPU) are shared among all running tasks
Advantages of Time-Sharing OS
Resource Sharing: Time-sharing systems allow multiple users to share hardware resources such as
the CPU, memory, and peripherals, reducing the cost of hardware and increasing efficiency.
Improved Productivity: Time-sharing allows users to work concurrently, reducing the waiting time for
their turn to use the computer. This increased productivity translates to more work getting done in
less time.
Improved User Experience: Time-sharing provides an interactive environment that allows users to
communicate with the computer in real-time, providing a better user experience than batch
processing.
o The multitasking environment makes several processors busier simultaneously; that is, the CPU
generates more heat.
o Managing different tasks altogether requires a more sophisticated algorithm, which becomes
complex to administer.
o Running too many applications simultaneously can stress the system to a point where performance
degrades.
o In this scenario, multiple tasks will compete for the same resources, thereby delaying them.
o Multitasking systems usually require more powerful hardware, especially memory and processing
power, to run without a hitch.
In Multiprocessing, Parallel computing is achieved. There is more than one processor in the system, which
can execute more than one process simultaneously. This will increase the system's throughput.
o In multiprocessing, several processors execute procedures in collaboration. You can even split a
procedure into parts that run in parallel.
o Since several processors work concurrently, more tasks are completed faster.
o Multiprocessing enhances the speed at which the system executes since tasks scatter the processors,
minimizing the procedure waiting period.
o If one processor is faulty, the others will continue running, enhancing system reliability.
Such an operating system is suited for highly computationally intensive environments needing high
processing power, such as scientific simulations, real-time data processing, and server environments.
Examples: Linux, Windows Server, macOS, Unix.
Working
In a Multiprocessing OS, concurrent execution of processes by multiple processors is done. The processes are
divided and allotted to different processors for parallel computing. Thus, system performance is enhanced
due to high throughput, good resource allocation, smooth distribution of workload on the processors, and
fault tolerance. If one of its processors fails, then the system can continue and reallocate its tasks to other
processors, and thus, the operation can be done smoothly.
o Example: Most modern operating systems like Linux, Windows, and macOS support SMP.
o Processors have their own memory and communicate via a high-speed interconnect.
o Increased Reliability: Because multiple processors are present, if one fails, others may take over it,
thus stabilizing the system.
o Increased Throughput: More jobs can be processed at the same time by these multiple processors
than by a single processor, thereby increasing the speed of execution.
o Efficient Resource Utilization: It acts more productively upon the utilization of resources like CPU,
memory, and I/O devices.
o Parallelism: Many processes can run parallel, which increases the speed of execution to a large
extent.
o Scalability: As the workload increases, more processors can be added to enhance performance.
o Complexity: There is a rise in the system's complexity while dealing with several processors and
proper distribution of tasks.
o Increased Cost: Hardware equipment added in multiprocessing systems increases their cost
o Communication Overhead: Generally, communication among processors results in overhead and
provides a slight reduction in efficiency.
o Software Compatibility Problems: Most software is not designed to operate properly with
multiprocessing systems.
[Link] Time Operating System
A Real-Time Operating System is conceived as a design for tasks that need to be completed under very strict
time constraints. In such systems, each task has a clear deadline; failing to achieve completion by that
deadline can, in turn, bring about significant consequences. Completion by the deadline may result in either
a critical failure or something no longer of relevance. It is commonly used in applications where timing and
precision are critical, such as embedded systems, robotics, and medical devices.
Types of Real-Time Operating Systems
Advantages of RTOS
Disadvantages of RTOS
Applications of RTOS
1. Embedded Systems: Automotive control systems, home appliances, and IoT devices.
2. Medical Devices: Heart rate monitors, ventilators, and surgical robots.
3. Industrial Automation: Robotics, assembly lines, and process control systems.
4. Telecommunications: Call switching systems and base stations.
5. Aerospace and Defense: Missile systems, flight control, and satellite systems.
1. Resource Sharing: Users can access resources like storage, processors, and peripherals across nodes.
2. Scalability: Easily add more nodes to increase computing power or storage.
3. Reliability: Redundancy and fault tolerance minimize the risk of downtime.
4. Performance: Parallel processing reduces task execution time.
5. Flexibility: Resources and tasks can be reallocated dynamically based on load.
Google File System (GFS): Used in Google’s data centers for large-scale data storage.
Apache Hadoop: Framework for distributed storage and processing of big data.
Distributed versions of UNIX: Amoeba, Plan 9.
Microsoft Azure OS: Underpins Microsoft’s cloud platform.
1. Cloud Computing:
o Services like AWS, Microsoft Azure, and Google Cloud rely on distributed systems.
2. Scientific Computing:
o Large-scale simulations, weather forecasting, and genome sequencing.
3. Big Data Processing:
o Frameworks like Hadoop and Spark for data analytics.
Operating systems provide a wide range of services to ensure smooth interaction between the user,
hardware, and software applications. These services are essential for managing system resources, running
applications, and ensuring user convenience and system efficiency.
1. User Services: Directly assist users in interacting with the computer system.
2. System Services: Manage system resources and support the execution of user applications.
1. Program Execution
Loads a program into memory, executes it, and ensures proper termination.
Handles errors during execution and allocates resources.
2. I/O Operations
Provides mechanisms for input/output operations, abstracting hardware details.
Allows interaction with devices like keyboards, mice, printers, and disk drives.
3. File Management
4. Memory Management
5. Process Management
7. Communication Services
Enables inter-process communication (IPC) within the same or across different systems.
Provides mechanisms like message passing, shared memory, and networking.
9. Resource Allocation
Allocates system resources (CPU, memory, I/O devices) efficiently to multiple users and tasks.
Ensures fair and optimal usage of resources.
System calls
A system call is a programmatic way in which a computer program requests a service from the kernel of the
operating system on which it is executed. A system call allows programs to interact with the operating
system. A computer program makes a system call when it requests the operating system’s kernel. The kernel
is a core component of an operating system and serves as the primary interface between the computer's
physical hardware and the processes running on it. The kernel enables multiple applications to share
hardware resources by providing access to CPU, memory, disk I/O, and networking. System call provides the
operating system's services to the user programs via the Application Program Interface (API). System calls
are the only entry points into the kernel system and are executed in kernel mode.
A user program can interact with the operating system using a system call. Many services are
requested by the program, and the OS responds by launching several systems calls to fulfill the
request.
A system call can be written in high-level languages like C or Pascal or in assembly language. If a
high-level language is used, the operating system may directly invoke system calls, predefined
functions.
A system call is initiated by the program executing a specific instruction, which triggers a switch to
kernel mode, allowing the program to request a service from the OS. The OS then handles the
request, performs the necessary operations, and returns the result back to the program.
System calls are essential for properly functioning an operating system, as they provide a
standardized way for programs to access system resources. Without system calls, each program
must implement its methods for accessing hardware and system services, leading to inconsistent
and error-prone behavior.
o Device Management
o Information Maintenance
o Communication
Interface: System calls provide a well-defined interface between user programs and the operating
system. Programs make requests by calling specific functions, and the operating system responds by
executing the requested service and returning a result.
Protection: System calls are used to access privileged operations that are not available to normal
user programs. The operating system uses this privilege to protect the system from malicious or
unauthorized access.
Kernel Mode: When a system call is made, the program is temporarily switched from user mode
to kernel mode. In kernel mode, the program has access to all system resources, including hardware,
memory, and other processes.
Context Switching: A system call requires a context switch, which involves saving the state of the
current process and switching to the kernel mode to execute the requested service. This can
introduce overhead, which can impact system performance.
Error Handling: System calls can return error codes to indicate problems with the requested service.
Programs must check for these errors and handle them appropriately.
Users need special resources: Sometimes programs need to do some special things that can’t be
done without the permission of the OS like reading from a file, writing to a file, getting any
information from the hardware, or requesting a space in memory.
The program makes a system call request: There are special predefined instructions to make a
request to the operating system. These instructions are nothing but just a “system call”. The
program uses these system calls in its code when needed.
Operating system sees the system call: When the OS sees the system call then it recognizes that the
program needs help at this time, so it temporarily stops the program execution and gives all the
control to a special part of itself called ‘Kernel’. Now ‘Kernel’ solves the need of the program.
The operating system performs the operations: Now the operating system performs the operation
that is requested by the program. Example: reading content from a file etc.
Operating system gives control back to the program: After performing the special operation, OS
gives power back to the program for further execution.
Open(): Accessing a file on a file system is possible with the open() system call. It gives the file
resources it needs and a handle the process can use. A file can be opened by multiple processes
simultaneously or just one process. Everything is based on the structure and file system.
Read(): Data from a file on the file system is retrieved using it.
Wait(): In some systems, a process might need to hold off until another process has finished
running before continuing. When a parent process creates a child process, the execution of the
parent process is halted until the child process is complete. The parent process is stopped using the
wait() system call. The parent process regains control once the child process has finished running.
Write(): Data from a user buffer is written using it to a device like a file. A program can produce
data in one way by using this system call.
Fork(): The fork() system call is used by processes to create copies of themselves. It is one of the
most frequently used methods in operating systems to create processes. When a parent process
creates a child process, the parent process’s execution is suspended until the child process is
finished. The parent process regains control once the child process has finished running.
Exit(): A system call called exit() is used to terminate a program. In environments with multiple
threads, this call indicates that the thread execution is finished. The operating system recovers the
process's resources after using the exit() system function.
Advantages:
Layering makes it easier to enhance the operating system, as the implementation of a layer can be
changed easily without affecting the other layers.
It is very easy to perform debugging and system verification.
Disadvantages:
In this structure, the application’s performance is degraded as compared to simple structure.
It requires careful planning for designing the layers, as the higher layers use the functionalities of
only the lower layers.
Micro-Kernel Structure
This 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. The advantages of this structure are that all new services need to be added to user space and do not
require the kernel to be modified. Thus, it is more secure and reliable as if a service fails, then the rest of
the operating system remains untouched. Mac OS is an example of this type of OS.
Advantages of Micro-kernel Structure
It makes the operating system portable to various platforms.
As microkernels are small, they can be tested effectively.
Disadvantages of Micro-kernel Structure
Increased level of inter-module communication degrades system performance.
Virtual machine
A virtual machine (VM) is a software-based computer that acts like a physical computer. VMs run on a
physical host machine, but each VM has its operating system. A virtual machine (VM) is a virtual
environment that functions as a virtual computer system with its own CPU, memory, network interface, and
storage created on a physical hardware system.
VMs are isolated from the rest of the system, and multiple VMs can exist on a single piece of hardware,
like a server. That means it is a simulated image of application software and operating system executed on a
host computer or a server. It has its own operating system and software that will facilitate the resources to
virtual computers. In short, a Virtual Machine provides a simulated computing environment that behaves
like a physical computer, allowing multiple OSes and applications to run on a single physical machine. It is
a crucial technology in modern data centers, cloud computing, and development environments.
Characteristics of virtual machines:
Multiple OS systems use the same hardware and partition resources between virtual computers.
Separate Security and configuration identity.
Ability to move the virtual computers between the physical host computers as holistically integrated
files.