Unit I - Introduction to Operating System and Process ( 09 Hours )
Introduction to operating systems, Types of OS, real time OS, the Linux Operating Systems
Process: process abstraction, system calls for process management, process creation: process states,
data structures, process execution mechanisms process api, process control and users
Introduction to OS:
An operating system acts as an intermediary between the user of a computer and computer
hardware. In short it’s an interface between computer hardware and user.
• 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 correct operation of the
computer system and to prevent user programs from interfering with the proper operation
of the system.
• The operating system (OS) is a program that runs at all times on a computer. All other
programs, including application programs, run on top of the operating system.
Types of Operating Systems:
There are several types of Operating Systems which are mentioned below.
1. Batch Operating System
2. Multi-Programming System
3. Multi-Processing System
4. Multi-Tasking Operating System
5. Time-Sharing Operating System
6. Distributed Operating System
7. Network Operating System
8. Real-Time Operating System
1. Batch Operating System
This type of operating system does not interact with the computer directly. There is an
operator which takes similar jobs having the same requirement and groups them into
batches. It is the responsibility of the operator to sort jobs with similar needs.
Batch Operating System
Advantages of Batch Operating System
• It is very difficult to guess or know the time required for any job to complete.
Processors of the batch systems know how long the job would be when it is in the
queue.
• Multiple users can share the batch systems.
• The idle time for the batch system is very less.
• It is easy to manage large work repeatedly in batch systems.
Disadvantages of Batch Operating System
• The computer operators should be well known with batch systems.
• Batch systems are hard to debug.
• It is sometimes costly.
• The other jobs will have to wait for an unknown time if any job fails.
Examples of Batch Operating Systems: Payroll Systems, Bank Statements, etc.
2. Multi-Programming Operating System
Multiprogramming Operating Systems can be simply illustrated as more than one
program is present in the main memory and any one of them can be kept in execution.
This is basically used for better execution of resources.
In multiprogramming system, multiple programs are to be stored in memory and each
program has to be given a specific portion of memory which is known as process.
The operating system handles all these processes and their states. Below are the steps
occur when the process undergoes execution:
• The operating system selects a ready process by checking which one process should
undergo execution.
• When the chosen process undergoes CPU execution, it might be possible that in
between process need any input/output operation.
• At that time process goes out of main memory for I/O operation and temporarily
stored in secondary storage.
• Then, CPU switches to next ready process.
• When the process which undergoes for I/O operation comes again after completing
the work
• Then, CPU switches to this process.
• This switching is happening so fast and repeatedly that creates an illusion of
simultaneous execution.
Multi Programming
Advantages of Multi-Programming Operating System
• Multi Programming increases the Throughput of the System.
• It helps in reducing the response time.
Disadvantages of Multi-Programming Operating System
• There is not any facility for user interaction of system resources with the system.
3. Multi-Processing Operating System
Multi-Processing Operating System is a type of Operating System in which more than
one CPU is used for the execution of resources. It betters the throughput of the System.
Multiprocessing
Multiprocessor system means, there are more than one processor which work parallel to
perform the required operations.
It allows the multiple processors, and they are connected with physical memory,
computer buses, clocks, and peripheral devices.
The main objective of using a multiprocessor operating system is to increase the
execution speed of the system and consume high computing power.
The different fields of multiprocessor operating systems used are as follows −
Asymmetric Multiprocessor − Every processor is given seeded tasks in this operating
system, and the master processor has the power for running the entire system. In the
course, it uses the master-slave relationship.
Symmetric Multiprocessor − In this system, every processor owns a similar copy of the
OS, and they can make communication in between one another. All processors are
connected with peering relationship nature, meaning it won’t be using master & slave
relation.
Advantages of Multi-Processing Operating System
• It increases the throughput of the system.
• As it has several processors, so, if one processor fails, we can proceed with another
processor.
Disadvantages of Multi-Processing Operating System
• Due to the multiple CPU, it can be more complex and somehow difficult to
understand.
4. Multi-Tasking Operating System
Multitasking Operating System is simply a multiprogramming Operating System with
having facility of a Round-Robin Scheduling Algorithm. It can run multiple programs
simultaneously.
There are two types of Multi-Tasking Systems which are listed below.
• Pre-emptive Multi-Tasking
• Cooperative Multi-Tasking
Advantages of Multi-Tasking Operating System
• Multiple Programs can be executed simultaneously in Multi-Tasking Operating
System.
• It comes with proper memory management.
Disadvantages of Multi-Tasking Operating System
• The system gets heated in case of heavy programs multiple times.
5. Time-Sharing Operating Systems
Each task is given some time to execute so that all the tasks work smoothly. Each user
gets the time of the CPU as they use a single system. These systems are also known as
Multitasking Systems. The task can be from a single user or different users also. The time
that each task gets to execute is called quantum. After this time interval is over OS
switches over to the next task.
Advantages of Multi-Tasking Operating System
• Multiple Programs can be executed simultaneously in Multi-Tasking Operating
System.
• It comes with proper memory management.
Disadvantages of Multi-Tasking Operating System
• The system gets heated in case of heavy programs multiple times.
5. Time-Sharing Operating Systems
Each task is given some time to execute so that all the tasks work smoothly. Each user
gets the time of the CPU as they use a single system. These systems are also known as
Multitasking Systems. The task can be from a single user or different users also. The time
that each task gets to execute is called quantum. After this time interval is over OS
switches over to the next task.
Advantages of Time-Sharing OS
• Each task gets an equal opportunity.
• Fewer chances of duplication of software.
• CPU idle time can be reduced.
• 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, thereby
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.
Disadvantages of Time-Sharing OS
• Reliability problem.
• One must have to take care of the security and integrity of user programs and data.
• Data communication problem.
• High Overhead: Time-sharing systems have a higher overhead than other operating
systems due to the need for scheduling, context switching, and other overheads that
come with supporting multiple users.
• Complexity: Time-sharing systems are complex and require advanced software to
manage multiple users simultaneously. This complexity increases the chance of bugs
and errors.
• Security Risks: With multiple users sharing resources, the risk of security breaches
increases. Time-sharing systems require careful management of user access,
authentication, and authorization to ensure the security of data and software.
6. Distributed Operating System
These types of operating system is a recent advancement in the world of computer
technology and are being widely accepted all over the world and, that too, at a great pace.
Various autonomous interconnected computers communicate with each other using a
shared communication network. Independent systems possess their own memory unit and
CPU.
These are referred to as loosely coupled systems or distributed systems. These systems’
processors differ in size and function. The major benefit of working with these types of
the operating system is that it is always possible that one user can access the files or
software which are not actually present on his system but some other system connected
within this network i.e., remote access is enabled within the devices connected in that
network.
Advantages of Distributed Operating System
• Failure of one will not affect the other network communication, as all systems are
independent of each other.
• Electronic mail increases the data exchange speed.
• Since resources are being shared, computation is highly fast and durable.
• Load on host computer reduces.
• These systems are easily scalable as many systems can be easily added to the network.
• Delay in data processing reduces.
Disadvantages of Distributed Operating System
• Failure of the main network will stop the entire communication.
• To establish distributed systems the language is used not well-defined yet.
• These types of systems are not readily available as they are very expensive. Not only
that the underlying software is highly complex and not understood well yet.
Examples of Distributed Operating Systems are LOCUS, etc.
Real time Operating System:
An RTOS or real-time operating system is a special-purpose OS for computers that
must accomplish tasks within severe time limitations. It is primarily used in systems
where the results of calculations are used to impact a process as it is running.
When an event occurs outside of the computer, it is conveyed to the computer via a
sensor that is used to monitor the event. The sensor generates a signal that the OS
interprets as an interrupt. When the operating system receives an interrupt, it starts a
specific process or a collection of processes to handle it.
Unless and until a higher priority interrupt occurs during its execution, this process is
fully uninterrupted. As a result, the interruptions must be prioritised in a specific order.
The highest priority interrupt should be permitted to start the process, and the lower
priority interrupts must be stored in a buffer and handled later. In such an OS, interrupt
management is critical.
Because standard operating systems cannot achieve such performance, real-time
operating systems need special-purpose operating systems.
The following are some examples of real-time operating systems:
• Lynx
• MTS
• VxWorks
• MTS
Applications
Real-time operating systems (RTOS) are employed in real-time applications that must
meet strict deadlines. The following are some of the most common applications of real-
time operating systems.
• The radar device.
• Missile guidance
• Online inventory trade
• Air Craft System
• Medical Imaging Systems.
• The traffic control System
• In autopilot trip simulators
Types of Real-time OS
•
1. Hard RTOS (Real-Time Operating System)
In a hard RTOS, all important tasks must be completed on time. If even a small delay
happens, it can cause serious damage or even danger to life.
Example:
• Airbags in cars: They must open instantly during a crash. A small delay can cause
injury.
• Online stock trading: If a stock isn’t sold on time, the user may lose money if
prices fall.
2. Soft RTOS
In a soft RTOS, tasks have deadlines, but a small delay is acceptable. It won’t cause
major problems.
Example:
• Online payment systems or price quote systems: A slight delay is okay and won’t
affect users much.
3. Firm RTOS
• Firm RTOS also tries to meet deadlines, but missing them won’t cause serious damage, just
some negative effects, like lower product quality.
Example: A delay may not stop the system, but it could reduce how well it performs.
Linux Operating Systems:
Linux is based on the UNIX operating system. UNIX is a powerful, multi-user,
multitasking operating system originally developed in the 1970s at AT&T Bell Labs.
It laid the foundation for many modern operating systems, including Linux.
• Linux is free and open-source, accessible to everyone.
• Its source code can be inspected and modified by anyone.
• This promotes global collaboration and innovation.
• Linux offers efficient performance and strong security.
• It works well across many devices and industries.
Linux Architecture
HARDWARE: physical parts of a computer, such as central processing unit (CPU),
monitor, mouse, keyboard, hard disk and other connected devices to CPU.
KERNEL: A kernel is a computer program and is the central, core part of an operating
system. It manages the operations of the computer and the hardware, most notably memory
and CPU time. It is an integral part of any operating system.
1. Kernel is core (main) part of Linux operating system.
2.It is collection of routine communicate with hardware directly.
3. It loads into memory when Linux is booted.
4. Kernel provides support to user programs through system call.
5. Kernel manages Computer memory, schedules processes, decides priorities of processes
and performs other tasks.
6. Kernel does lot of work even if no application software is running.
7. Hence kernel often called as application software gateway to the computer resources.
SHELL: Shell is an environment in which we can run our commands, programs, and shell
scripts. It is a user interface for access to an operating system's services. (User interface
program execution, file system manipulation, input/output operations, communication,
resource allocation, error detection, security and protection)
1. Shell is interface between user and kernel.
2. It is outer part of operating system.
3. A shell is a user interface for access to an operating system's services Shell is an
environment in which we can run our commands, programs, softwares and shell scripts.
Application programs/software: An application, or application program, is a software
program that runs on your computer. It is excited by user. Some inbuilt application
programs in Linux are terminal, Firefox browser, Libre office
Advantages of Linux
• The main advantage of Linux is it is an open-source operating system you can
contribute, modify, and distribute the code freely.
• In terms of security, Linux is more secure than any other operating system and does
not require any anti-virus software.
• The software updates in Linux are easy and frequent.
• Linux is freely available to use on the internet.
• It provides high stability it rarely slows down or freezes and there is no need to reboot
it after a short time.
Disadvantages of Linux
• It is not very user-friendly. So, it may be confusing for beginners.
• It has small peripheral hardware drivers as compared to windows.
Process abstraction :
Process abstraction is one of the most fundamental concepts in an operating system. It's
the mechanism the OS uses to create the illusion that each program you run has exclusive
access to the computer's resources, even when many programs are running at the same time
on a single CPU.
In simple terms, process abstraction takes a static program (a set of instructions on a disk)
and gives it a life of its own as a "process," which is an active, executing instance of that
program. The OS handles all the complexity of managing and sharing the underlying
hardware, so the program itself doesn't need to worry about it.
Here's a more detailed breakdown:
The Problem Without Abstraction
Imagine you have a computer with a single CPU and 4 GB of RAM. Now you want to run
a web browser, a word processor, and a music player at the same time.
• CPU: How does the single CPU run all three programs simultaneously? It can't. It
has to switch between them.
• Memory: How do all three programs fit into the same 4 GB of RAM without
overwriting each other's data?
• Files: What if two programs try to access the same file at the same time?
If a programmer had to write code to handle all these scenarios for every single program,
it would be an impossible task. The code would be incredibly complex, prone to errors,
and would need to be rewritten for every new computer architecture.
The Solution: Process Abstraction
The operating system solves this problem with process abstraction. It creates a virtualized
environment for each program, which we call a process.
A process is more than just a program's code; it's a complete execution environment. It
includes:
1. Code and Data: The actual program instructions and its initial data.
2. State (CPU Context): All the information the CPU needs to run the program at a
specific moment. This includes the program counter (which tells the CPU which
instruction to execute next), the values in the registers, and the stack pointer.
3. Address Space: A virtualized view of memory. The OS gives each process its own
isolated "address space," so it thinks it has all the memory to itself. The OS then
maps these virtual addresses to actual physical memory locations, ensuring that one
process cannot access another's memory.
4. Open Resources: A list of the files, network connections, or other devices the
process is currently using.
Key Aspects of Process Abstraction
• Virtualizing the CPU: The OS uses a technique called time-sharing to create the
illusion of multiple CPUs. It rapidly switches the single physical CPU between
different processes. This is known as a context switch. The OS saves the state of
the current process, loads the state of the next process, and lets it run for a short
period before repeating the cycle. To the user, it looks like all programs are running
at the same time.
• Virtualizing Memory: The OS uses a technique called virtual memory to give
each process its own isolated address space. This protects processes from each other
and prevents a buggy program from crashing the entire system.
• Protection and Isolation: A core part of process abstraction is providing a
protection boundary. One process cannot directly interfere with another. This
ensures that a bug in your web browser won't cause your music player to crash.
• Simplifying Programming: From a programmer's perspective, they don't need to
worry about any of this. They write their program as if it's the only one running on
the machine. The OS handles all the messy details of resource sharing and
protection, allowing them to focus on the application logic.
In essence, process abstraction is the OS's way of simplifying a complex system. It
turns the tangled mess of shared hardware into a clean, well-defined, and isolated "process"
for each application, making the computer usable and reliable.
System calls for process management:
A system call is a mechanism that allows a computer program to request a service from the
operating system's kernel. Essentially, it's a way for user-level programs to interact with
the low-level functions of the OS, such as accessing hardware or managing processes
A system is used to create a new process or a duplicate process called a fork.
The duplicate process consists of all data in the file description and registers common. The
original process is also called the parent process and the duplicate is called the child
process.
The fork call returns a value, which is zero in the child and equal to the child’s PID (Process
Identifier) in the parent. The system calls like exit would request the services for
terminating a process.
Loading of programs or changing of the original image with duplicate needs execution of
exec. Pid would help to distinguish between child and parent processes.
Process management system calls in Linux:
• fork − For creating a duplicate process from the parent process.
• wait − Processes are supposed to wait for other processes to complete their work.
• exec − Loads the selected program into the memory.
• exit − Terminates the process.
fork() − A parent process always uses a fork for creating a new child process. The child
process is generally called a copy of the parent. After execution of fork, both parent and
child execute the same program in separate processes.
exec() − This function is used to replace the program executed by a process. The child
sometimes may use exec after a fork for replacing the process memory space with a new
program executable making the child execute a different program than the parent.
exit() − This function is used to terminate the process.
wait() − The parent uses a wait function to suspend execution till a child terminates. Using
wait the parent can obtain the exit status of a terminated child.
Process Life Cycle
When a process executes, it passes through different states. These stages may differ in
different operating systems, and the names of these states are also not standardized.
In general, a process can have one of the following five states at a time.
S.N. State & Description
Start
1
This is the initial state when a process is first started/created.
Ready
The process is waiting to be assigned to a processor. Ready processes are
waitingto have the processor allocated to them by the operating system so that
2
they can run. Process may come into this state after Start state or while running
it by but interrupted by the scheduler to assign CPU to some other process.
3 Running
Once the process has been assigned to a processor by the OS scheduler, the process
state is set to running and the processor executes its instructions.
Waiting
4 Process moves into the waiting state if it needs to wait for a resource, such as
waiting for user input, or waiting for a file to become available.
Terminated or Exit
Once the process finishes its execution, or it is terminated by the operating system,
5 it is moved to the terminated state where it waits to be removed from mainmemory.
Process Control Block (PCB)
A Process Control Block is a data structure maintained by the Operating System for
every process. The PCB is identified by an integer process ID (PID). A PCB keeps all
theinformation needed to keep track of a process as listed below in the table –
S.N. Information & Description
Process State
1 The current state of the process i.e., whether it is ready, running, waiting,
orwhatever.
Process privileges
2
This is required to allow/disallow access to system resources.
Process ID
3
Unique identification for each of the process in the operating system.
Pointer
4
A pointer to parent process.
Program Counter
5 Program Counter is a pointer to the address of the next instruction to be
executedfor this process.
CPU registers
6 Various CPU registers where process need to be stored for execution for
runningstate.
CPU Scheduling Information
7 Process priority and other scheduling information which is required to schedule
theprocess.
Memory management information
8 This includes the information of page table, memory limits, Segment table
depending on memory used by the operating system.
Accounting information
9 This includes the amount of CPU used for process execution, time limits,
executionID etc.
IO status information
10
This includes a list of I/O devices allocated to the process.
The architecture of a PCB is completely dependent on Operating System and may
contain different information in different operating systems. Here is a simplified
diagram of a PCB −
Process API in Operating Systems:
The Process API refers to the set of system calls or functions provided by the
Operating System (OS) that allow programs (or users) to create, manage, and control
processes. These APIs are crucial for multitasking and managing how programs run on
your computer.
process is a running instance of a program. The OS must provide ways to:
1. Create a new process
2. Terminate a process
3. Wait for a process to finish
4. Control and get info about a process
Main Process API Functions
Let’s look at the major actions provided by a typical Process API (like in UNIX/Linux):
Function Description
Creates a new process by duplicating the calling
fork()
process
Replaces the current process image with a new
exec()
program
wait() Makes a process wait until its child finishes
exit() Terminates a process and returns status to parent
getpid() Gets the Process ID (PID) of the current process
getppid() Gets the PID of the parent process
1. fork() – Creating a Process
• fork() creates a child process, which is a copy of the parent.
• Returns 0 to the child, and returns child PID to the parent.
• Both processes continue running independently.
2. exec() – Running a New Program
• Used to replace the current process with a new program.
• Usually used after fork() in the child process.
• Has several versions like execl(), execp(), execv(), etc.
wait() – Waiting for Child
• Allows a parent to wait for a child to finish execution.
• Prevents zombie processes (processes that have finished but not cleaned up).
4. exit() – Terminating a Process
• Ends the current process and returns an exit status.
• The status can be picked up by the parent using wait().
5.getpid() and getppid()
• getpid() returns the current process’s ID.
• getppid() returns the parent process’s ID.