1. Operating systems are an essential part of any computer system that act as an interface between the user and hardware. They manage computer resources like the CPU, memory, disk space, and I/O devices.
2. The course covers fundamental operating system concepts like processes, process scheduling, memory management, security and protection, virtualization, distributed systems, and kernel data structures.
3. Key topics include operating system operations, resource management, security methods like authentication and protection from threats, virtual machine architecture, features of distributed systems, and important kernel data structures for process and file management.
2. Operating Systems are an essential part of any
computer system. Similarly, a course on operating systems is an essential
part of any computer science education. This field is undergoing rapid
changes and advancements, as computers are now prevalent in virtually
every arena of day-to-day life. Yet the fundamental concepts remain
fairly clear and same till now, and it is on these that we discuss in this
course.
3. UNIT - 1 [ 12 Periods ]
Introduction: What Operating Systems Do, Operating-System Operations, Resource
Management, Security and Protection, Virtualization, Distributed Systems, Kernel Data
Structures.
Operating System Structures: Operating-System Services, User and Operating-System
Interface, System Calls, Operating-System Structure.
Processes: Process Concept, Process Scheduling, Operations on Processes, Inter process
Communication, IPC in shared-memory Systems, IPC in Message-passing Systems.
SUBJECT CODE - CD/CM/CO/CS/IT (R 20)
DETAILS - IoT IV SEM - MARCH 2023
FACULTY DETAILS - PRUDHVI KIRAN P, Asst. Prof., CSE (IoT), RVR&JC College of Engineering
4. QUESTION BANK - UNIT 1 [Assignment Questions - 4, 8, 11]
1. Define Operating System (OS) in detail. What are the operations of OS?
2. Explain in detail about Security and Protection offered by Operating System.
3. What is the Virtualization? Draw and explain the Virtual Machine Architecture of OS.
4. Draw and explain the structure of Distributed Systems (DS). What Are the features of DS?
5. What is Kernel? What are the various kernel data structures used in Operating System?
6. Explain and differentiate GUI and CLI ?
7. Define System Call with valid block diagram. What are the different types of System Calls in OS?
8. Discuss about various types of Operating System structures?
9. What is a Process? Draw and explain the Process Life Cycle. What are the operations performed
on the process?
10. Draw and Explain in detail about the process control block (PCB) and Process Layout.
11. What is the importance of Process Scheduling and what are the types of available schedulers?
12. Explain IPC in Shared Memory systems and Message Passing systems with appropriate block
diagrams.
END
5. 1.1.1 What Operating Systems Do
Computer System comprises of Hardware and Software,
Hardware can only understand machine code (in the form of 0
and 1) which doesn't make any sense to a naive user.
Operating System is an interface which can act as an
intermediary between user and hardware accomplishing many
tasks, providing an environment in which a user can work with
computer in convenient and efficient manner. Operating System
is responsible for;
• Resource Allocation
• Process Management
• Process Synchronization
• Memory Management
• CPU Scheduling
• File Management
• Device Management
• Security
6. The KERNEL is a computer program at
the core of a computer's operating system
and generally has complete control over
everything in the system. It is the portion of
the operating system code that is always
resident in memory and facilitates
interactions between hardware and software
components. Kernel can be called as heart of
operating system.
7. 1.1.2 Operating System Operations
An operating system is a construct that allows the
user application programs to interact with the
system hardware. Operating system by itself does
not provide any function but it provides an
atmosphere in which different applications and
programs can do their work. The major operations
of the operating system are; Process management,
Memory management, Device management and File
management.
Process Management
The operating system is responsible for managing
the processes i.e. assigning the processor to a
process at a time. This is known as process
scheduling.
The different algorithms used for process scheduling
are FCFS (first come first served), SJF (shortest job
first), Priority Scheduling etc.
8. There are many scheduling queues that are used to handle processes in process management.
When the processes enter the system, they are put into one of these job queues. The processes
that are ready to execute in the main memory are kept in the ready queue. The processes that
are waiting for the I/O device are kept in the device queue.
Memory Management
Memory management plays an important part in operating system. It deals with memory and
the moving of processes from disk to primary memory for execution and back again. The
activities performed by the operating system for memory management are;
• The operating system assigns memory to the processes as required. This can be done using best
fit, first fit and worst fit algorithms.
• All the memory is tracked by the operating system i.e. it nodes what memory parts are in use by
the processes and which are empty.
• The operating system deallocates memory from processes as required. This may happen when a
process has been terminated or if it no longer needs the memory.
Device Management
There are many I/O devices handled by the operating system such as mouse, keyboard, disk
drive etc. There are different device drivers that can be connected to the operating system to
handle a specific device. The user applications can access all the I/O devices using the device
drivers.
9. File Management
Files are used to provide a uniform view of data storage by the operating system. All the files are
mapped onto physical devices that are usually non volatile so data is safe in the case of system
failure. The files can be accessed by the system in two ways i.e. sequential access and direct
access;
• Sequential Access
The information in a file is processed in order using sequential access. The files records are
accessed on after another. Most of the file systems such as editors, compilers etc. use
sequential access.
• Direct Access
In direct access or relative access, the files can be accessed in random for read and write
operations. The direct access model is based on the disk model of a file, since it allows
random accesses.
Resource Management is a crucial component of operating system that manages computer
resources such as CPU, memory, disk space, and input/output devices. The operating system must
manage the use of hardware resources so that software can complete its tasks without any
hassles.
1.1.3 Resource Management
11. 1.1.4 Security and Protection
Protection and security are the two sets of techniques used by OS to ensure that computer
resources such as CPU, Software, Memory etc. are protected. Security and Protection can be
achieved by confidentiality (prevention of unauthorized resources and modification), integrity
(prevention of all unauthorized users), and availability (unauthorized withholding of resources).
Protection tackles the system's internal threats. It
provides a mechanism for controlling access to processes,
programs, and user resources. In simple words, It specifies
which files a specific user can access or view and modify
to maintain the proper functioning of the system.
Security tackles the system's external threats. The safety
of their system resources such as saved data, disks,
memory, etc. is secured by the security systems against
harmful modifications, unauthorized access, and
inconsistency. It provides a mechanism (encryption and
authentication) to analyse the user before allowing access
to the system.
12. Threats to Protection and Security
Virus
Viruses are generally small snippets of code embedded in a system. They are very dangerous and
can corrupt files, destroy data, crash systems etc. They can also spread further by replicating
themselves as required.
Trojan Horse
A trojan horse can secretly access the login details of a system. Then a malicious user can use
these to enter the system as a harmless being and wreak havoc.
Worm
A worm can destroy a system by using system’s resources to extreme levels. It can generate
multiple copies which claim all the resources and don't allow any other processes to access them.
A worm can shut down a whole network in this way.
Denial of Service
These type of attacks do not allow the legitimate users to access a system. It overwhelms the
system with requests so it is overwhelmed and cannot work properly for other user.
13. Protection and Security Methods
Authentication
This deals with identifying each user in the system and making sure they are who they claim to be.
The operating system makes sure that all the users are authenticated before they access the system.
• Username/ Password
Each user has a distinct username and password combination.
• User Key/ User Card
The users need to punch a card into the card slot or use their individual key on a keypad.
• User Attribute Identification
Fingerprint, Eye retina etc. These are unique for each user and are compared with the existing
___samples in the database.
One Time Password
These passwords provide a lot of security for authentication purposes. A one time password can be
generated exclusively for a login every time a user wants to enter the system. It cannot be used more
than once.
• OTP, Captcha
• Secret Key Generation Devices (RSA Token)
14. SECURITY is a broad term in which more complex
queries are handled while PROTECTION comes
under security and handles less complex issues. The
protection involves the internal type of threat
whereas in security external threats are also involved.
15. 1.1.5 Virtualization
Operating system-based Virtualization refers to an
operating system feature in which the kernel
enables the existence of various isolated user-
space instances.
The installation of virtualization software also
refers to Operating system-based virtualization.
Virtualization is done through software on a pre-
existing operating system and that operating
system called as the host operating system.
A virtual machine monitor (VMM), also known as
a hypervisor, is a software, hardware, or firmware-
based process that manages the creation and
operation of virtualized environments from the
host system. VMM also monitors the usage and
performance of associated VMs.
16. "Bare Metal" hypervisors runs guest virtual machines directly on a system's hardware where as
Hosted hypervisors behave more like traditional applications that can be started and stopped
like a normal program.
To the applications running on top of the virtualized machine, it can appear as if they are on
their own dedicated machine, where the operating system, libraries, and other programs are
unique to the guest virtualized system and unconnected to the host operating system which sits
below it.
There are many reasons why people utilize virtualization in computing. To desktop users, the
most common use is to be able to run applications meant for a different operating system
without having to switch computers or reboot into a different system.
For administrators of servers, virtualization also offers the ability to run different operating
systems, but perhaps, more importantly, it offers a way to segment a large system into many
smaller parts, allowing the server to be used more efficiently by a number of different users or
applications with different needs.
Virtualization also allows for process isolation, which means keeping programs running inside of
a virtual machine safe from the processes taking place in another virtual machine on the same
host.
17. REPRESENTATION OF TRADITIONAL AND VIRTUAL OPERATING SYSTEM
TRADITIONAL OS VIRTUAL OS
A container is actually just an isolated process that shared the same Linux kernel of the host
operating system, as well as the libraries and other files needed for the execution of the program
running inside of the container, often with a network interface such that the container can be
exposed to the world in the same way as a virtual machine. Containers are not full, independent
machines. They are designed to run a single program but can't emulate a full multi-purpose server,
as Virtual Machine.
CONTAINER IS NOT VIRTUAL MACHINE
18. 1.1.6 Distributed Systems
Distributed Operating System is a type of
model where applications are running on
multiple computers linked by
communications and supports and
integration of the machines on the network.
Distributed OS runs on multiple CPUs but
for an end-user, it is just an ordinary
centralized operating system. It can share
all resources like CPU, disk, network
interface, nodes, computers, etc. from one
site to another site.
All processors are connected by valid
communication media such as high-speed
buses (LAN/WAN) and telephone lines, and
in which every processor contains its own
local memory.
19. THERE ARE THREE TYPES OF DISTRIBUTED OS
The Distributed OS is used to a large extent in the organization. Because of more usage the Protection
and Security feature of OS come into the scene to preserve the system from any cause of damage or
data loss from external/internal sources and keep it protected.
PROTECTION AND SECURITY IN DISTRIBUTED OS
Client-Server System/Tightly Coupled System
This type of system requires the client to request a resource, after which the server gives the
requested resource. When a client connects to a server, the server may serve multiple clients at the
same time.
Peer-to-Peer System/Loosely Coupled System
The nodes play an important role in this system. The task is evenly distributed among the nodes.
Additionally, these nodes can share data and resources as needed. Remember that, they require a
network to connect.
Middleware
Middleware enables the interoperability of all applications running on different operating systems.
Those programs are capable of transferring all data to one other.
20. Openness
It means that the system's services are freely displayed through interfaces. Furthermore, these
interfaces only give the service syntax. For example, the type of function, its return type,
parameters, and so on.
Scalability
It refers to the fact that the system's efficiency should not vary as new nodes are added to the
system. Furthermore, the performance of a system with 100 nodes should be the same as that of a
system with 1000 nodes.
Transparency
It is the most important feature of the distributed operating system. The primary purpose of a
distributed operating system is to hide the fact that resources are shared. Transparency also implies
that the user should be unaware that the resources he is accessing are shared from other systems.
Heterogeneity
The components of distributed systems may differ and vary in operating systems, networks,
programming languages, computer hardware, and implementations by different developers.
FEATURES OF DISTRIBUTED OPERATING SYSTEM
21. Fault Tolerance
Fault tolerance is that process in which user may continue their work if the software or hardware
fails.
Resource Sharing
Its most essential feature is that it allows users to share resources. They can also share resources in
a secure and controlled manner. Printers, files, data, storage, web pages, etc., are examples of shared
resources.
Banking applications
Stock exchange applications
Web browsers
Streaming services
Rideshare applications
Food delivery applications; and.
Massively multiplayer online games
EXAMPLE APPLICATIONS OF DISTRIBUTED OPERATING SYSTEM
Wide range of DOS applications also include; Network Applications, Telecommunication Networks
Applications, Parallel Computation Applications, Real-Time Process Control Applications. Distributed
Operating System (DOS) can be considered as an extension to Network Operating System (NOS).
22. ADVANTAGES AND DISADVANTAGES OF DISTRIBUTED OPERATING SYSTEM
ADVANTAGES
It may share all resources (CPU, disk, network interface, nodes, computers, and so on) from one
site to another, increasing data availability across the entire system.
It reduces the probability of data corruption because all data is replicated across all sites; if one
site fails, the user can access data from another operational site.
The entire system operates independently of one another, and as a result, if one site crashes,
the entire system does not halt.
It helps in the reduction of data processing time.
DISADVANTAGES
The system must decide which jobs must be executed, when and where they must be executed.
Scheduler limitations, sometimes can lead to underutilized hardware and unpredictable
runtimes.
Security is typical since all the connected nodes and connection mediums of DOS must be
secured.
The database connected to a DOS is hard to manage in contrast to a single-user system. The
more widely distributed a system is, the more communication latency may be seen.
23. 1.1.7 Kernel Data Structures
The kernel data structures are very important as they store data about the current state of the
system. For example, if a new process is created in the system, a kernel data structure is created
that contains the details about the process.
Most of the kernel data structures are only accessible by the kernel and its subsystems. They
may contain data as well as pointers to other data structures.
The kernel stores and organizes a lot of information. So it has data about which processes are
running in the system, their memory requirements, files in use etc. To handle all this, three
important Kernal Data Structures are used;
1. Process Table
2. File Table
3. V Node and I Node Information
1. Process Table
The process table stores information about all the processes running (active) in the system.
These include the storage information, execution status, file information etc. The fork system
call is used to create a new processes. The newly created process is the child process. The
process which calls fork and creates a new process is the parent process.
24. 2. File Table
The file table contains entries about all the files in the system. Each file table entry contains
information about the file such as file status (file read or file write), file offset (the position in the
file for next read or write). If multiple processes utilize the same file, the file information and file
descriptor number are the same. The file table also contains v-node and i-node pointers which
point to the virtual node and index node respectively. These nodes contain information on how
to read/write a file.
3. V Node and I Node Information
Both the v-node (Virtual Node) and i-node (Index Node) are references to the storage system of
the file and the storage mechanisms. They connect the hardware to the software. The v-node
defines the method to access file data without worrying about the actual structure of the
system.
The i-node specifies file access information like file storage device, read/write procedures etc.
The location of the disc block where the file is kept, the time at which the file was last changed,
the owner of the file, access privileges (read/write), and so on. Secondary storage is used to
store i-node data.
Process table contains details like; Process state (new, active, running or terminated), Process ID
(used to identify the process), User ID (specifies the rights granted to users for the specific
process).
26. UNIT - 1 [ 12 Periods ]
Introduction: What Operating Systems Do, Operating-System Operations, Resource
Management, Security and Protection, Virtualization, Distributed Systems, Kernel Data
Structures.
Operating System Structures: Operating-System Services, User and Operating-System
Interface, System Calls, Operating-System Structure.
Processes: Process Concept, Process Scheduling, Operations on Processes, inter process
Communication, IPC in shared-memory Systems, IPC in Message-passing Systems.
SUBJECT CODE - CD/CM/CO/CS/IT (R 20)
DETAILS - IoT IV SEM - MARCH 2023
FACULTY DETAILS - PRUDHVI KIRAN P, Asst. Prof., CSE (IoT), RVR&JC College of Engineering
27. 1.2.1 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. Below are the few common services provided by an operating system;
1. Program execution/management
2. I/O operations
3. File System manipulation
4. Communication
5. Error Detection
6. Resource Allocation
7. Protection
1. Program execution
Operating systems handle many kinds of activities from user programs to system programs, which
includes the complete execution context.
28. 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.
2. I/O operations
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 operations provides the access to the required I/O device when required and takes care of
read/write operation with any specific I/O device.
3. File System manipulation
Operating System makes sure that, a file system is normally organized into directories for easy
navigation and usage. These directories may contain files and other directories.
29. 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.
4. 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. The OS handles routing and connection strategies, and the problems of contention
and security.
• 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.
Following are the major activities of an operating system with respect to communication;
30. 5. Error Detection
Errors can occur anytime and anywhere. An error may occur in CPU, in I/O devices or in the
memory hardware. The OS constantly checks for possible errors and takes appropriate action to
ensure correct and consistent computing.
6. Resource Allocation
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. The OS manages all kinds of resources
using schedulers, where CPU scheduling algorithms are used for better utilization of CPU.
7. Protection
Considering a computer system having multiple users and concurrent execution of multiple
processes; 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.
The OS ensures that all access to system resources is controlled and the external I/O devices are
protected from invalid access attempts. OS also provides authentication features for each user by
means of passwords.
31. 1.2.2 User and Operating-System Interface
Any device’s operating system is nothing but an interface between the hardware components
and its user. The operating system enables the interaction between the user and the device by
providing two user interfaces. In computers there are different interfaces which are not always
necessarily used but can be used whenever it is needed. Different types of tasks can be
performed by the help of different interfaces.
Below are the two types of interfaces created by an operating system allowing user to work with
the hardware components of system.
1. Command line interface
2. Graphical user interface
1. Command line interface (CLI)
The command-line interface is an interface where the user needs to enter different commands
regarding the input and output for a task to be performed. So this is called the command-line
interface. It is used to execute the programs and create, delete, print, copy, paste and many
operations on files. The CLI is basically a medium or a platform, where a user writes a command
to answer a visual prompt and then receives a response from the system/device.
32. 2. Graphical user interface (GUI)
GUI lets a user interact with the OS/system’s hardware with the help of graphical elements, like
windows, menus, icons, etc. In a GUI, you get various menus in applications for making things easy,
such as buttons, windows, scrollbars, wizards, alternative icons, painting pictures, etc. It is very
intuitive yet simple to use, even for a newbie. The basic components of GUIs are Desktop screen,
Different icons and shortcuts, Start menu with program groups, Taskbar which showing running
programs, etc.
GUI CLI
33. PARAMETERS CLI GUI
Ease of Use
It is comparatively more difficult to
understand and use.
It is comparatively easier to
understand and use.
Memory Consumption
CLI consumes comparatively less
memory.
The GUI consumes comparatively
more memory.
Level of Precision
Higher precision of work can be
obtained using CLI.
GUI offers a lower level of precision.
Speed
It works at a higher speed as
compared to the GUI.
It works at a much slower speed as
compared to the CLI.
Keyboard and Mouse
Its OS only requires a user’s
keyboard.
Its OS requires both keyboard and
mouse to work.
Modification of
Appearance
We cannot change or modify the CLI
operating system’s appearance.
We can change or modify the GUI
operating system’s appearance.
Graphics No graphs are included in CLI. Graphics are always used in the GUI.
Menus No menus are provided in CLI. The GUI OS comes with menus.
Understanding CLI & GUI Comparatively …
34. PARAMETERS CLI GUI
Display of Information
The information that the user
wants to view is displayed in files
and plain text.
The information that the user wants to
access is presented in various forms, like
plain text, images, videos, gifs,
videographs, etc.
Input of Information
The input is usually entered at the
command prompt in CLI.
We can input the data anywhere on the
computer screen in the case of GUI.
Pointing device Usage
Pointing devices are not used at all
in CLI.
We use pointing devices in the GUI for
choosing/selecting the items we want
to.
Typing Errors
No typing errors or spelling
mistakes can be avoided by CLI.
The typing errors or spelling mistakes
cannot be avoided by the GUI.
Regular Tasks Store regularly used scripts.
Can be automated using batch files up
to some extent.
Memorizing Procedure
User should memorize commands
and a complex syntax.
User should memorize the process, which is
easier than memorizing complex commands.
35. Both the CLI and the GUI have benefits and limitations, and they are chosen by the user depending
on the user's needs and usage. The GUI allows for more multitasking and efficiency and on the other
hand the CLI allows for more control, precision, and reliability.
GUI is not resource optimized. The aim is to make a user-friendly interface, and as such, it uses
more computer memory and Compared to CLI, GUI uses more processing power.
Remembering a large number of commands makes it challenging to use CLI, even for
experienced users. CLI leaves a small room for error. Mistyped commands may not get processed
correctly and in case of mistyped instructions, you may need to start from scratch again.
Notable Drawbacks Discussion (Inverse description can be a Advantage) …
CLI IN DIFFERENT OS’s
Windows: Command Prompt.
Linux: Linux Bash Shell.
MacOs: Mac Terminal.
36. 1.2.3 System Calls
A system call is a way for a user program to interface with the operating system. The program
requests several services, and the OS responds by invoking a series of system calls to satisfy the
request. A system call can be written in assembly language like Pascal. System calls are predefined
functions that the operating system may directly invoke if a high-level language like C is used.
Having an Idea on Languages used in Computer
Assembly
code
The translation of a single statement of the
source program into machine code is done by a
language processor and executes immediately
before moving on to the next line is called an
interpreter. If there is an error in the statement,
the interpreter terminates its translating process
at that statement and displays an error message.
37. A system call is a method for a computer program to request a service from the kernel of the
operating system on which it is running. A system call is a method of interacting with the operating
system via programs. A system call is a request from computer software to an operating system's
kernel.
The processes execute normally in
the user mode until a system call
interrupts this. Then the system
call is executed on a priority basis
in the kernel mode. After the
execution of the system call, the
control returns to the user mode
and execution of user processes
can be resumed.
System calls are usually made
when a process in user mode
requires access to a resource. Then
it requests the kernel to provide
the resource via a system call.
SYSTEM CALLS: Creation or Deletion of Files | Reading and Writing
from Files | Creation and Management of New Processes | Network
Connections | Access to a hardware devices
38. There are primarily 5 different types of system calls in the operating system:
1. Process Control
2. File Management
3. Device Management
4. Information Maintenance
5. Communication
1. Process Control
• To forcefully abort the process.
• Simply end it normally.
• Terminate the current process before starting a new one.
• Allocate memory to a process, then release the memory if the process is terminated.
• Wait for a process to complete running/wait until a specific event happens, then announce it
once it has.
2. File Management
• Making and erasing files, Open the file, then close it.
• Write to a specific file, read from a specific file and to obtain a file's attribute and to change a
file's attribute
39. 3. Device Management
• Ask for a device and then release it once the task is complete.
• When a requested device is granted access by the process, it is capable of reading and writing.
• Obtain or modify a specific device's attributes.
4. Information Maintenance
• Obtain the system's time or date. Set the system's time or date.
• Obtain system-related information. Configure the system data.
• Obtain the characteristics/ Set the characteristics of a specific operating system process.
Alternatively, of a specific file on the system or on any attached devices.
5. Communication
• Open a fresh connection to send the data. After the transmission is finished, disconnect from the
connection.
• On a particular connection, send a message. Obtain communication from a specific connection.
• Identify and connect a specific remote device to the network. Remove a specific remote
computer or device from the network.
40. OS in view of Services, System Calls & User Interfaces
41. The fork() and exec() System Calls
Every application(program) comes into execution through means of process, process is a running
instance of a program. Processes are created through different system calls, most popular are
fork() and exec()
The fork () system call aids in the creation of processes. When a process uses the fork() system call,
it creates a replicate of itself. The parent process is the existing process, and the child process is the
new process. Although, the child process is equivalent to the parent process. When creating the
child process, the parent state like open files, address space, and variables are copied to the child
process.
The exec() system call is used to make the processes. When the exec() function is used, the
currently running process is terminated and replaced with the newly formed process. In other
words, only the new process persists after calling exec(). The parent process is shut down. This
system call also substitutes the parent process's text segment, address space, and data segment
with the newly created process.
42. 1.2.4 Operating-System Structure
An operating system is a design that enables user application programs to communicate with
the hardware of the machine.
The operating system should be built with the utmost care so that it should be simple to use
and modify, even though is such a complicated structure.
The operating system structure illustrates the organization of modules inside it. The structure of
the operating system varies from system to system and OS structure on each of these systems
should be well defined with clear inputs, outputs and functions.
Different types of Operating System Structures;
1. Simple Structure
2. Monolithic Structure
3. Layered Structure
4. Microkernels Structure
5. Exokernel Structure
6. Client-Server Structure
7. Virtual Structure
43. 1. Simple Structure
Simplest Operating System Structure is not well
defined; It can only be used for small and limited
systems. In this structure, the interfaces and
levels of functionality are well separated; hence
programs can access I/O routines which can
cause unauthorized access to I/O routines.
Such structure is implemented in MS-DOS
operating system, in MS-DOS various layers are
present, each with its own set of functions.
Layering has an advantage in the MS-DOS
operating system since all the levels can be
defined separately and can interact with each
other when needed.
The abstraction level in MS-DOS systems is low,
so programs and I/O routines are visible to the
end-user, so the user can have unauthorized
access.
(Basic Input/Output System)
44. Advantages of Simple Structure
It is easier to design, maintain, and update the system if it is made in layers. So that's why limited
systems with less complexity can be constructed easily using Simple Structure. And also offers
good performance due to lesser layers between hardware and applications.
Disadvantages of Simple Structure
The abstraction level is low, so programs and I/O routines are visible to the end-user, so the user
can have unauthorized access of the processes which are active and running in the Operating
System, which can lead to data modification and can cause Operating System to crash.
45. 2. Monolithic Structure
In Monolithic operating system structure the kernel acts as a manager and manages all things
like process management, file management, memory management, device management.
In monolithic systems, kernels can directly access all the resources of the operating System like
physical hardware, keyboard, Mouse etc and delivers basic services to all other elements of the
System
USER MODE is an unprivileged
mode, and has restricted access to
system resources. Kernel mode is the
privileged mode and has the full
access to system resources and
serves the user.
46. Advantages of Monolithic Structure
It is simple to design and implement because all operations are managed by kernel only, and
layering is not needed.
As services such as memory management, file management, process scheduling, etc., are
implemented in the same address space, the execution of the monolithic kernel is relatively fast
as compared to normal systems. Using the same address saves time for address allocation for new
processes and makes it faster.
Disadvantages of Monolithic Structure
If any service in the monolithic kernel fails, the entire System fails because, in address space, the
services are connected to each other and affect each other.
It is not flexible to introduce a new service.
47. 3. Layered Structure
In Layered operating system structure, OS is broken into a number of layers (levels). The bottom
layer (layer 0) is the hardware; the highest layer is the user interface.
Each layer is implemented only with operations provided by lower-level layers. A layer does not
need to know how these operations are implemented; it needs to know only what these
operations do.
All these layers are arranged in a hierarchical way in which the top-level layers use the
functionalities of their lower-level levels.
48. Advantages of Layered Structure
Layering makes it easier to enhance the operating system as implementation of a layer can be
changed easily without affecting the other layers. And also it is very easy to perform debugging
and system verification.
Disadvantages of Layered Structure
It requires careful planning for designing the layers as higher layers use the functionalities of only
the lower layers.
49. 4. Microkernels Structure
Micro-Kernel structure designs the
Operating System by separating all
non-essential components of the
kernel. These non-essential
components of kernels are
implemented as Micro-Kernels.
Advantages of Microkernel Structure
It makes the operating system
portable to various platforms. And as
microkernels are small so these can
be tested effectively.
Disadvantages of Microkernel Structure
Increased level of inter module
communication degrades system
performance.
• IPC is the way by which multiple processes or threads
communicate with each other.
• Virtual Memory is a storage scheme that provides user
an illusion of having a very big main memory (RAM);
this is done to address, RAM shortage.
50. 5. Exokernel Structure
Exokernel is an operating system, that
seeks to provide application-level
management of hardware resources
by separating resource protection from
Kernel (Management). This can avoid
the impact on the performance,
functionality and scope of applications,
seen in Conventional operating
systems.
Advantages of Microkernel Structure
Application performance is enhanced
by it as there will be effective
utilization of hardware resources by
applications.
Disadvantages of Microkernel Structure
Exokernel interfaces have a complex
architecture.
• The idea is to eliminate the notion that an
operating system must provide abstractions. This
impose as few abstractions as possible on the
developers and provide them with the liberty to
use hardware with out any abstractions whenever
needed.
51. 6. Client-Server Structure
The client and server processes communicate with each other by passing messages. The client
process initiates by constructing a message and send it to the intended service providing server.
The message illustrates what the client requires. The server responds and sends the result to
the requesting client process in the form of a message.
Client-Server scenario can be applicable when the client and server may run on the same
system or can run on different systems connected by the network.
Advantages of Microkernel Structure
As the data is centralized, this system
is more secure and serves added
security to the data.
Disadvantages of Microkernel Structure
If all the clients simultaneously
request data from the server, it may
get overloaded.
52. 7. Virtual Machine Structure
The hardware of our personal computer,
including the CPU, disc drives, RAM, and NIC
(Network Interface Card), is abstracted by a
virtual machine into a variety of various
execution contexts based on our needs, giving us
the impression that each execution
environment is a separate computer.
Advantages of Microkernel Structure
Due to total isolation between each virtual
machine and every other virtual machine, there
are no issues with security.
Disadvantages of Microkernel Structure
Depending on the workload, operating
numerous virtual machines simultaneously on a
host computer may have an adverse effect on
one of them.
53. UNIT - 1 [ 12 periods ]
Introduction: What Operating Systems Do, Operating-System Operations, Resource
Management, Security and Protection, Virtualization, Distributed Systems, Kernel Data
Structures.
Operating System Structures: Operating-System Services, User and Operating-System
Interface, System Calls, Operating-System Structure.
Processes: Process Concept, Process Scheduling, Operations on Processes, inter process
Communication, IPC in shared-memory Systems, IPC in Message-passing Systems.
SUBJECT CODE - CD/CM/CO/CS/IT (R 20)
DETAILS - IoT IV SEM - MARCH 2023
FACULTY DETAILS - PRUDHVI KIRAN P, Asst. Prof., CSE (IoT), RVR&JC College of Engineering
54. 1.3.1 Process Concept
A process is defined as a sequence of instructions
executed in a predefined order. In simple words, any
program that is executed is termed as a process.
Processes change its state as it executes and can be either
new, ready, running, waiting or terminated. A process in
OS is managed by the Process Control Block (PCB).
When you write a set of actions in sequential order, it is
called a program. The program, when in execution is
called a process. A single program can host numerous
processes and these processes can be run more than one
time. Within an Operating System (OS), we have
numerous kinds of processes.
An OS serves in the creation, scheduling and termination
of processes. The OS consists of Process Control Block
(PCB) that helps control the functioning of processes.
Every process in OS has a PCB associated with it. PROCESS CONTROL BLOCK (PCB)
Process ID
55. A PCB comprises of the following information regarding a process:
1. Process ID: An identifier that helps us in identifying and locating a process.
2. Process state: It identifies the state that the process is currently in. It could be a new process,
ready, running, waiting or terminated.
3. Program counter: It holds the address of the next instruction to be executed in the process
(program). It also stores a count of the number of instructions in the process.
4. CPU registers: When the process is in a running state, different kinds of information is stored in
CPU registers, like accumulators, instruction registers, condition code registers, index and
general-purpose registers.
5. CPU scheduling information: A process needs to be scheduled for execution. Based on this
scheduling, it goes from ready to running. CPU Scheduling information contains process priority
(to determine which process goes first), pointers for scheduling queues (to mark the order of
execution), and various other scheduling parameters.
6. Accounting and business information: Contains details like CPU utilization, real-time used by the
process, number of jobs or processes, etc.
56. 7. Memory-management information: Contains the value of base and limit registers which
addresses the logic address space that can be utilized by the process in execution
8. I/O status information: Comprises I/O related information including list of I/O devices allocated
to the process, status, etc.
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. The following
image shows a simplified layout of a process inside main memory.
Process Layout:
1. Stack - This section contains local variables, functions and returns
address. As soon as function return the values stack section for that
function will get deleted.
C Programming Example Scenario to understand
This function when called will be stored in
stack section.
57. 3. Heap - This Section is used to provide dynamic memory whenever memory is required by the
program during runtime. Dynamic memory needs to be handled i.e. freed when there is no
need of it, otherwise heap will become full after some time.
4. Data - This section contains the global and static variables.
5. Text - This section contains the executable instruction, constants, and macros, it is read-only
location and is sharable so that can be used by another process also.
In C language: malloc() and calloc() is used for this purpose. A statement like: malloc(4) will return
the starting address of the 4 BYTE block which is in heap area. After the utilization of the memory,
free() function is used in the C program to do so.
C Programming Example Scenario to understand
C Programming Example Scenario to understand
A global variable can be accessed from
anywhere inside the program while a static
variable only has a block scope
58. 1.3.2 Operations on Process
The execution of a process is a complex activity. It involves various operations. Following are the
major operations that are performed while execution of a process; Process Creation, Process
Preemption, Process blocking, and Process termination.
1. Process Creation
Processes need to be created in the system for different operations. This can be done by the
following events;
• User request for process creation
• System initialization
• Execution of a process creation system call by a running process
A process may be created by another process using fork(). The creating process is called the
parent process and the created process is the child process. A child process can have only one
parent but a parent process may have many children.
2. Process Preemption
An interrupt mechanism is used in preemption that suspends the process executing currently
and the next process to execute is determined by the short-term scheduler.
59. 3. Process Blocking
A process that is blocked is one that is waiting for some event, such as waiting for a resource
becoming available or the completion of an I/O operation with the resource. After the event is
complete, i.e. when the resource is available or the operation is completed, the process again
goes to the ready state from waiting state.
4. Process Termination
After the process has completed the execution of its last instruction, it is terminated. The
resources held by a process are released after it is terminated.
A child process can be terminated by its parent process if its task is no longer relevant. The child
process sends its status information to the parent process before it terminates. Also, when a
parent process is terminated, its child processes are terminated
Process Lifecycle in contrast with the operations on process:
When a process executes, it passes through different states while the above mentioned
operations are applied. In general, a process can have one of the following five states at a time,
and these stages combined is mentioned as the life cycle of a process, that starts with the Start
State, which is initial state when a process is first started/created and ends with the terminated
state, once the process finishes its execution, or it is terminated by the operating system.
61. 1.3.3 Process Scheduling
The act of determining which process is in the ready state, and should be moved to the running
state is known as Process Scheduling.
The prime aim of the process scheduling system is to keep the CPU busy all the time and to
deliver minimum response time for all programs. Swapping of processes, i.e. IN and OUT of CPU
is done by the scheduler on the basis of a particular strategy. Scheduling fell into one of the two
general categories:
• Non Preemptive Scheduling is When the currently executing process gives up the CPU
voluntarily. Hence the resource can’t be taken from a process until the process completes
execution.
• Preemptive Scheduling is when the OS may allocate the resources to a process for a fixed
amount of time or the OS may give priority to other processes and replace the current executing
process higher priority process.
Schedulers available are of three types
1. Long - Term Scheduler
2. Short - Term Scheduler
3. Medium - Term Scheduler
62. 1. Long - Term Scheduler
Long term scheduler is also known as job scheduler. It chooses the processes from the pool
(secondary memory) and keeps them in the ready queue maintained in the primary memory.
Long Term scheduler mainly controls the degree of Multiprogramming. The purpose of long
term scheduler is to choose a perfect mix of IO bound and CPU bound processes among the
jobs present in the pool.
I/O-bound tasks are which use much of their time in input and output operations while CPU-
bound processes are which spend their time on the CPU. The job scheduler increases efficiency
by maintaining a balance between the two. They operate at a high level and are typically used in
batch-processing systems.
For an instance if the job scheduler chooses more IO bound processes then all of the jobs may
reside in the blocked state all the time and the CPU will remain idle most of the time. This will
reduce the degree of Multiprogramming. Therefore, the Job of long term scheduler is very
critical and may affect the system for a very long time.
2. Short - Term Scheduler
Short term scheduler is also known as CPU scheduler. It selects one of the Jobs from the ready
queue and dispatch to the CPU for the execution.
63. That means, the Short - Term scheduling algorithm is used to select which job is going to be
dispatched for the execution. The Job of the short term scheduler can be very critical in the
sense that if it selects job whose CPU burst time is very high then all the jobs after that, will
have to wait in the ready queue for a very long time. This problem is called starvation which may
arise if the short term scheduler makes some mistakes while selecting the job.
3. Medium - Term Scheduler
Medium term scheduler takes care of the swapped out processes. If the running state processes
needs some IO time for the completion then there is a need to change its state from running to
waiting.
Medium term scheduler is used for this purpose. It removes the process from the running state
to make room for the other processes. Such processes are the swapped out processes and
these processes are swapped into ready state later after completion of their I/O task and then to
running , this procedure is called swapping. The medium term scheduler is responsible for
suspending and resuming the processes, i.e. The process is swapped out, and is later swapped
in, by the medium term scheduler.
What is Context Switch?
Switching the CPU to another process requires saving the state of the old process and loading the
saved state for the new process. This task is known as a Context Switch.
64. 1.3.4 Inter process Communication
Interprocess communication (IPC) is the mechanism provided by the operating system that
allows processes to communicate with each other.
This communication could involve a process letting another process know that some event has
occurred or the transferring of data from one process to another.
PROCESSS 1 PROCESSS 2
IPC
Approaches to Interprocess Communication
1. Pipe
A pipe is a data channel that is unidirectional. Two pipes can be used to create a two-way data
channel between two processes.
2. Socket
The socket is the endpoint for sending or receiving data in a network. This is true for data sent
between processes on the same computer or data sent between different computers on the same
network.
65. 3. File
A file is a data record that may be stored on a disk or acquired on demand by a file server. Multiple
processes can access a file as required.
4. Signal
Signals are useful in interprocess communication in a limited way. They are system messages that are
sent from one process to another. Normally, signals are not used to transfer data but are used for
remote commands between processes.
5. Shared Memory
Shared memory is the memory that can be simultaneously accessed by multiple processes. This is
done so that the processes can communicate with each other.
6. Message Queue
Multiple processes can read and write data to the message queue without being connected to each
other. Messages are stored in the queue until their recipient retrieves them.
A system can have two types of processes, Independent Process and Cooperating Process.
Cooperating processes affect each other and may share data and information among themselves
using IPC.
66. IPC allows processes to share data with
each other. This can be useful in situations
where one process needs to access data
that is held by another process.
IPC allows processes to share resources
such as memory, files, and devices. This
can help reduce the amount of memory or
disk space that is required by a system.
IPC allows processes to synchronize their
activities. For example, one process may
need to wait for another process to
complete its task before it can continue.
IPC allows processes to be designed in a
modular way, with each process
performing a specific task. This can make it
easier to develop and maintain complex
systems.
IPC can add complexity to the design and
implementation of software systems, as it
requires careful coordination and
synchronization between processes. This can
lead to increased development time and
maintenance costs.
IPC can introduce security vulnerabilities, as it
creates additional attack surfaces for malicious
actors to exploit. For example, a malicious
process could attempt to gain unauthorized
access to shared resources or data.
IPC can also create compatibility issues
between different systems, as different
operating systems and programming
languages may have different IPC mechanisms
and APIs. This can make it difficult to develop
cross-platform applications that work
seamlessly across different environments.
IPC ADVANTAGES IPC DISADVANTAGES
67. 1.3.5 IPC in shared-memory Systems
Process A and process B are executing
simultaneously and they share some
resources. Process1 generates data based on
computations in the code. Process1 stores
this data in shared memory. When process2
needs to use the shared data, it will check in
the shared memory segment and use the data
that process1 placed there. Processes can use
shared memory for extracting information as a
record from another process as well as for
delivering any specific information to other
processes.
Communication between processes using
shared memory requires processes to share
some variable information and it is usually left
up to the programmer to implement it.
68. 1.3.6 IPC in Message-passing Systems
In this method, processes communicate with
each other without using any kind of shared
memory. If two processes A and B want to
communicate with each other, they proceed as
follows:
• Establish a communication link (if a link
already exists, no need to establish it again.)
• Start exchanging messages using a system's
library functions send() and receive().
To send a message, Process A, sends a
message via the communication link that has
been opened between the 2 processes. Using
the send() function. Process B, which is
monitoring the communication link, uses the
receive() function to pick up the message.
69. S.No Shared Memory Model Message Passing Model
1
The shared memory region is used for
communication.
A message passing facility is used for
communication.
2
It is used for communication between processes on
a single processor or multiprocessor systems where
the communicating processes reside on the same
machine as the communicating processes share a
common address space.
It is typically used in a distributed
environment where communicating
processes reside on remote machines
connected through a network.
3
The code for reading and writing the data from the
shared memory should be written explicitly by the
Application programmer.
No such code required here as the message
passing facility provides mechanism for
communication and synchronization of
actions performed by the communicating
processes.
4
It provides a maximum speed of computation as
communication is done through shared memory so
system calls are made only to establish the shared
memory.
It is time-consuming as message passing is
implemented through kernel intervention
(system calls).
Understanding Shared Memory Model and Message Passing Model in IPC comparatively :
70. S.No Shared Memory Model Message Passing Model
5
Here the processes need to ensure that they are
not writing to the same location simultaneously.
It is useful for sharing small amounts of
data as conflicts need not to be resolved.
6 Faster communication strategy. Relatively slower communication strategy.
7 No kernel intervention. It involves kernel intervention.
8
It can be used in exchanging larger amounts of
data.
It can be used in exchanging small amounts
of data.
9
Examples
Data from a client process may need to be
transferred to a server process for modification
before being returned to the client.
Examples
Web browsers
Web Servers
Chat program on WWW (World Wide Web)
71. UNIT - 1 [ 12 periods ]
Introduction: What Operating Systems Do, Operating-System Operations, Resource
Management, Security and Protection, Virtualization, Distributed Systems, Kernel Data
Structures.
Operating System Structures: Operating-System Services, User and Operating-System
Interface, System Calls, Operating-System Structure.
Processes: Process Concept, Process Scheduling, Operations on Processes, inter process
Communication, IPC in shared-memory Systems, IPC in Message-passing Systems.
END OF UNIT 1
SUBJECT CODE - CD/CM/CO/CS/IT (R 20)
DETAILS - IoT IV SEM - MARCH 2023
FACULTY DETAILS - PRUDHVI KIRAN P, Asst. Prof., CSE (IoT), RVR&JC College of Engineering