Unit 1(introduction)OPERATING SYSTEMS
Unit 1(introduction)OPERATING SYSTEMS
Unit 1- Introduction:
Introduction to Operating System:
An operating system acts as an intermediary between the user
of a computer and computer hardware. In short its 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.
It does assignment of resources like memory, processors and
input / output devices to different processes that need the
resources. The assignment of resources has to be fair and
secure.
Functionalities of Operating System:
1. Resource Management: When multiple processes run on
the system and need different resource like memory, i/o
devices, the OS works as Resource manager , its responsibility is
to provide hardwre to the user. It decreases the load in the
system.
2. Process Management: it include task like scheduling and
Synchronization of process.
3. Storage Management: The file system mechanism used
for the management of the secondary storage like Hard
Disk. NIFS, CIFS, CFS, NFS, etc. All the data is stored in various
tracks of Hard disks that are all managed by the storage
manager.
4. Memory Management: Refers to the management of
primary memory, mainly allocation and de-allocation of
memory to processes. The operating system has to keep track
of how much memory has been used and by which process. It
has to decide which process needs memory space and how
much
5. Security/Privacy Management: Privacy is also provided
by the Operating system using passwords so that unauthorized
applications can’t access programs or data. For example,
Windows uses Kerberos authentication to prevent
unauthorized access to data.
.. .. .. .. .. …
Secondary Goals
1. Efficient Resource Utilization: It should aim to maximize the
performance and utilization of computer resources like CPU,
Memory and IO devices, ensuring that the system runs
smoothly and efficiently.
2. Reliability: It should be robust and reliable, able to handle
errors and exceptions gracefully, ensuring that the system
continues to operate smoothly. It should be modular in design
and easy to debug.
Characteristics of Operating Systems
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 that
decides which process gets the device, when and for how much
time.
File Management: It allocates and de-allocates the resources
and also decides who gets the resource.
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 dumps, traces, error messages and other
debugging and error-detecting methods.
Memory Management: It is responsible for managing
the primary memory of a computer, including what part of it
are in use by whom also check how much amount free or used
and allocate process
Processor Management: It allocates the processor to a process
and then de-allocates the processor 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: It prevents unauthorized access to programs and data
using passwords or some kind of protection technique.
Convenience: An OS makes a computer more convenient to
use.
Efficiency: An OS allows the computer system resources to be
used efficiently.
Ability to Evolve: An OS should be constructed in such a way as
to permit the effective development, testing and introduction
of new system functions at the same time without interfering
with service.
Throughput: An OS should be constructed so that It can give
maximum throughput (Number of tasks per unit time
Kernel:
The kernel is one of the components of the Operating System which
works as a core component. The rest of the components depends on
Kernel for the supply of the important services that are provided by
the Operating System. The kernel is the primary interface between
the Operating system and Hardware
The following functions are to be performed by the Kernel.
It helps in controlling the System Calls.
It helps in I/O Management.
It helps in the management of applications, memory, etc
Advantages
Multiple users can share the batch systems.
The idle time for the batch system is very little.
It is easy to manage large work repeatedly in batch systems.
Disadvantage:-
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 a batch operating system, average response time increases as
all processes are processed one by one.
2. Multi-Programming Os:-
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 used for better
utilization of resources.
A multiprogramming operating system allows multiple programs
to reside in memory simultaneously and share CPU time, even on
a single-processor computer.
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 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.
Examples:
IBM VM/CMS , TSO(time sharing option), Window terminal
services
8 Mobile Os:
Mobile operating systems are designed specifically for mobile
devices such as smartphones and tablets. Examples of such
operating systems are Android and iOS. These operating
systems manage the hardware and software resources of the
device, providing a platform for running applications and
ensuring a seamless user experience.
Advantages of Mobile Operating Systems
User-Friendly Interfaces: Mobile operating systems are
designed to be intuitive and easy to use, making them
accessible to a wide range of users.
Extensive App Ecosystems: The availability of a vast number
of applications allows users to customize their devices to
meet their specific needs.
Connectivity Options: Mobile operating systems support
multiple connectivity options, enabling users to stay
connected wherever they go.
Regular Updates: Mobile operating systems receive regular
updates, including new features, security patches, and
performance improvements.
Disadvantages Mobile Operating Systems
Battery Life Constraints: Despite advancements in power
management, battery life remains a challenge for mobile
devices, especially with heavy usage.
Security Risks: Mobile devices are susceptible to various
security threats, such as malware and phishing attacks, which
can compromise user data.
Fragmentation: In the case of Android, the wide range of
devices and customizations can lead to fragmentation,
making it difficult for developers to ensure compatibility
across all devices.
Limited Hardware Resources: Mobile devices have limited
processing power, memory, and storage compared to desktop
computers, which can affect the performance of resource-
intensive applications.
Microkernel in os:-
A MicroKernel is an approach to designing an Operating System (OS).
The microkernel provides very fundamental services required to run
the OS like basic memory management, task scheduling, etc.
Microkernels use Inter-Process Communication (IPC) for
communication
What is kernel:-
What is a microkernel:-
Microkernel is a type of Operating System that provides some basic
services for an operating system/ These services include memory
management, process scheduling, etc. Some other services like
Device Drivers, File Systems, etc are managed by user-level
processes. User Level Process communicates with Microkernel via
message passing. This way of handling the process makes
microkernels more modular and more flexible than traditional
monolithic kernels.
a microkernel architecture can provide a more secure and flexible
operating system, but it may also come with some performance and
complexity trade-offs. The choice between a microkernel and a
monolithic kernel architecture depends on the specific needs and
requirements of the operating system being developed.
Features of Microkernel-Based Operating System
Minimal Core : The kernel only manages basic tasks like CPU
scheduling, memory management, and inter-process
communication. All other services (like device drivers) run in
user space, outside the kernel.
Modularity : System services are separated into independent
modules. This makes it easy to update or replace individual
components without affecting the entire system.
Stability and Fault Isolation : If a service like a device driver
fails, it won’t crash the whole system. Each service runs
independently, so the core OS remains stable.
Ease of Maintenance : Since services are independent, fixing
bugs or adding new features doesn’t require major changes to
the kernel itself, making maintenance easier.
Advantages of Microkernel
Modularity: Because the kernel and servers can be developed
and maintained independently, the microkernel design allows
for greater modularity. This can make adding and removing
features and services from the system easier.
Performance: Because the kernel only contains the essential
functions required to manage the system, the microkernel
design can improve performance. This can make the system
faster and more efficient.
Security: The microkernel design can improve security by
reducing the system’s attack surface by limiting the functions
provided by the kernel. Malicious software may find it more
difficult to compromise the system as a result of this.
Reliability: Microkernels are less complex than monolithic
kernels, which can make them more reliable and less prone to
crashes or other issues.
Scalability: Microkernels can be easily scaled to support
different hardware architectures, making them more versatile.
Portability: Microkernels can be ported to different platforms
with minimal effort, which makes them useful for embedded
systems and other specialized applications.
Disadvantages of a Microkernel
Slower Message Passing: Slower message passing between
user-level processes can affect performance, especially in high-
performance applications.
More Complex: Increased complexity due to the modular
design can make it more difficult to develop and maintain
the operating system .
Limited Performance: Limited performance optimization due to
separation of kernel and user-level processes.
Higher Memory Usage: Higher memory usage compared to a
monolithic kernel.
Conclusion
In conclusion, a microkernel keeps the core of the operating
system small and simple, which makes it more secure and stable.
Since most functions run outside the kernel, it’s easier to fix or
update parts of the system without affecting everything else.
A microkernel focuses on running only the most essential tasks in
the core, such as managing memory and CPU, while leaving other
services like device drivers and file systems to run outside in user
space.
Processes In OS:-
A process is basically a program in execution. The execution of a
process must progress in a sequential fashion
A process is defined as an entity which represents the basic unit of
work to be implemented in the system.
To put it in simple terms, we write our computer programs in a
text file and when we execute this program, it becomes a process
which performs all the tasks mentioned in the program.
When a program is loaded into the memory and it becomes a
process,
it can be divided into four sections stack, heap, text and data.
1 Stack
The process Stack contains the temporary data such as
method/function parameters, return address and local
variables.
Heap
2 This is dynamically allocated memory to a process during its
run time.
Text
3 This includes the current activity represented by the value of
Program Counter and the contents of the processor's registers.
Data
4
This section contains the global and static variables.
Program:
A program is a piece of code which may be a single line or millions of
lines. A computer program is usually written by a computer
programmer in a programming language.
A computer program is a collection of instructions that performs a
specific task when executed by a computer.
A part of a computer program that performs a well-defined task is
known as an algorithm.
A collection of computer programs, libraries and related data are
referred to as a software.
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 waiting to have the processor allocated to them by
2 the operating system so that 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.
Running
Waiting
Terminated or Exit
S.N
Information & Description
.
Process State
1 The current state of the process i.e., whether it is ready,
running, waiting, or whatever.
Process privileges
2 This is required to allow/disallow access to system
resources.
3 Process ID
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 executed for this process.
CPU registers
6 Various CPU registers where process need to be stored for
execution for running state.
Accounting information
9 This includes the amount of CPU used for process
execution, time limits, execution ID etc.
IO status information
10
This includes a list of I/O devices allocated to the process.
Context switching In OS:-
Context switching in an operating system (OS) refers to the process
where the CPU switches from executing one process to another. This
involves saving the current state of the running process (its context)
and loading the state of the new process so it can resume execution
at the point where it was suspended. It's a fundamental mechanism
for enabling multitasking and allowing multiple processes to share
the CPU's resources.
1. Multitasking
In a multitasking environment, a process is switched out of the CPU
so another process can be run. The state of the old process is saved,
and the state of the new process is loaded. On a preemptive system,
processes may be switched out by the scheduler.
2. Interrupt Handling
The hardware switches a part of the context when an interrupt
occurs. This happens automatically. Only some of the context is
changed to minimize the time required to handle the interrupt.
Thread In OS:
A thread is a single sequence stream within a process. Threads are
also called lightweight processes as they possess some of the
properties of processes. Each thread belongs to exactly one process
In an operating system that supports multithreading, the
process can consist of many threads. But threads can be
effective only if the CPU is more than 1 otherwise two threads
have to context switch for that single CPU.
All threads belonging to the same process share – code section,
data section, and OS resources (e.g. open files and signals)
But each thread has its own (thread control block) – thread ID,
program counter, register set, and a stack
Any operating system process can execute a thread. we can say
that single process can have multiple threads.