OS NOTES - UNIT 1
OS NOTES - UNIT 1
OPERATING SYSTEM
Operating System lies in the category of system software. It basically manages all the
resources of the computer. An operating system acts as an interface between the
software and different parts of the computer or the computer hardware. The operating
system is designed in such a way that it can manage the overall resources and
operations of the computer.
Functions of
the Operating System
● Resource Management: The operating system manages and allocates
memory, CPU time, and other hardware resources among the various
programs and processes running on the computer.
● Process Management: The operating system is responsible for starting,
stopping, and managing processes and programs. It also controls the
scheduling of processes and allocates resources to them.
2
● Memory Management: The operating system manages the computer’s
primary memory and provides mechanisms for optimizing memory usage. ●
Security: The operating system provides a secure environment for the user,
applications, and data by implementing security policies and mechanisms
such as access controls and encryption.
● Job Accounting: It keeps track of time and resources used by various jobs or
users.
● File Management: The operating system is responsible for organizing and
managing the file system, including the creation, deletion, and manipulation
of files and directories.
● Device Management: The operating system manages input/output devices
such as printers, keyboards, mice, and displays. It provides the necessary
drivers and interfaces to enable communication between the devices and the
computer.
● Networking: The operating system provides networking capabilities such as
establishing and managing network connections, handling network
protocols, and sharing resources such as printers and files over a network.
● User Interface: The operating system provides a user interface that enables
users to interact with the computer system. This can be a Graphical User
Interface (GUI), a Command-Line Interface (CLI), or a combination of both.
● Backup and Recovery: The operating system provides mechanisms for
backing up data and recovering it in case of system failures, errors, or
disasters.
● Virtualization: The operating system provides virtualization capabilities that
allow multiple operating systems or applications to run on a single
3
physical machine. This can enable efficient use of resources and flexibility
in managing workloads.
● Performance Monitoring: The operating system provides tools for
monitoring and optimizing system performance, including identifying
bottlenecks, optimizing resource usage, and analyzing system logs and
metrics.
● Time-Sharing: The operating system enables multiple users to share a
computer system and its resources simultaneously by providing time sharing
mechanisms that allocate resources fairly and efficiently.
● System Calls: The operating system provides a set of system calls that enable
applications to interact with the operating system and access its resources.
System calls provide a standardized interface between applications and the
operating system, enabling portability and compatibility across different
hardware and software platforms.
● Error-detecting Aids: These contain methods that include the production of
dumps, traces, error messages, and other debugging and error-detecting
methods.
Distributed System
A distributed System is a collection of autonomous computer systems that are
physically separated but are connected by a centralized computer network that is
equipped with distributed system software. The autonomous computers will
communicate among each system by sharing resources and files and performing the
tasks assigned to them.
systems, industrial control systems, weapon systems, robots, air traffic control
systems, etc.
Parallel Systems are designed to speed up the execution of programs by dividing the
programs into multiple fragments and processing these fragments at the same time.
Flynn has classified computer systems into four types based on parallelism in the
instructions and in the data streams.
1. Single Instruction stream, single data stream
2. Single Instruction stream, multiple data stream
3. Multiple Instruction stream, single data stream
4. Multiple Instruction stream, multiple data stream
10
A multitasking operating system enables the execution of two or more programs at the same
time. The operating system accomplishes this by shifting each program into and out of memory
one at a time. When a program is switched out of memory, it is temporarily saved on disk until it
is required again.
A multiuser operating system allows many users to share processing time on a powerful central
computer from different terminals. The operating system accomplishes this by rapidly switching
between terminals, each of which receives a limited amount of processor time on the central
computer. The operating system changes among terminals so quickly that each user seems to
have continuous access to the central computer. If there are many users on a system like this, the
time it takes the central computer to reply can become more obvious.
11
What is a Process?
A process is an activity of executing a program. It is a program under execution. Every
process needs certain resources to complete its task. Processes are the programs that
are dispatched from the ready state and are scheduled in the CPU for execution. PCB
(Process Control Block) holds the context of the process. A process can create other
processes which are known as Child Processes. The process takes more time to
terminate, and it is isolated, meaning it does not share the memory with any other
process. The process can have the following states new, ready, running, waiting,
terminated, and suspended.
Operation on a Process
The execution of a process is a complex activity. It involves various operations.
Following are the operations that are performed while execution of a process:
1. Creation
This is the initial step of the process execution activity. Process creation means the
construction of a new process for execution. This might be performed by the system,
12
the user, or the old process itself. There are several events that lead to the process
creation. Some of the such events are the following:
● When we start the computer, the system creates several background
processes.
● A user may request to create a new process.
● A process can create a new process itself while executing.
● The batch system takes initiation of a batch job.
2. Scheduling/Dispatching
The event or activity in which the state of the process is changed from ready to run. It
means the operating system puts the process from the ready state into the running
state. Dispatching is done by the operating system when the resources are free or the
process has higher priority than the ongoing process. There are various other cases in
which the process in the running state is preempted and the process in the ready state
is dispatched by the operating system.
3. Blocking
When a process invokes an input-output system call that blocks the process, and
operating system is put in block mode. Block mode is basically a mode where the
process waits for input-output. Hence on the demand of the process itself, the
operating system blocks the process and dispatches another process to the processor.
Hence, in process-blocking operations, the operating system puts the process in a
‘waiting’ state.
4. Preemption
When a timeout occurs that means the process hadn’t been terminated in the allotted
time interval and the next process is ready to execute, then the operating system
preempts the process. This operation is only valid where CPU scheduling supports
preemption. Basically, this happens in priority scheduling where on the incoming of
13
high priority process the ongoing process is preempted. Hence, in process preemption
operation, the operating system puts the process in a ‘ready’ state.
5. Process Termination
Process termination is the activity of ending the process. In other words, process
termination is the relaxation of computer resources taken by the process for the
execution. Like creation, in termination also there may be several events that may lead
to the process of termination. Some of them are:
● The process completes its execution fully and it indicates to the OS that it has
finished.
● The operating system itself terminates the process due to service errors.
● There may be a problem in hardware that terminates the process.
Process Control Block
A Process Control Block (PCB) is a data structure used by the operating system to
manage information about a process. The process control keeps track of many
important pieces of information needed to manage processes efficiently. The diagram
helps explain some of these key data items.
14
PCB and written to the CPU registers. This is the main purpose of the
registers in the PCB.
● Memory limits: This field contains the information about memory
management system used by the operating system. This may include page
tables, segment tables, etc.
● List of Open files: This information includes the list of files opened for a
process.
2. Modularity
Modularity refers to the division of complex tasks into smaller subtasks. Different
cooperating processes can complete these smaller subtasks. As a result, the required tasks
are completed more quickly and efficiently.
16
3. Computation Speedup
4. Convenience
There are multiple tasks that a user requires to perform, such as printing, compiling,
editing, etc. It is more convenient if these activities may be managed through cooperating
processes.
1. Cooperation by sharing
The processes may cooperate by sharing data, including variables, memory, databases, etc.
The critical section provides data integrity, and writing is mutually exclusive to avoid
inconsistent data.
17
Here, you see a diagram that shows cooperation by sharing. In this diagram, Process P1
and P2 may cooperate by using shared data like files, databases, variables, memory, etc.
2. Cooperation by Communication
The cooperating processes may cooperate by using messages. If every process waits for a
message from another process to execute a task, it may cause a deadlock. If a process does
not receive any messages, it may cause starvation.
Here, you have seen a diagram that shows cooperation by communication. In this diagram,
User Level Thread is a type of thread that is not created using system calls. The
kernel has no work in the management of user-level threads. User-level threads
can be easily implemented by the user. In case when user-level threads are single
handed processes, kernel-level thread manages them. Let’s look at the advantages
and disadvantages of User-Level Thread.
A kernel Level Thread is a type of thread that can recognize the Operating
system easily. Kernel Level Threads has its own thread table where it keeps track
of the system. The operating System Kernel helps in managing threads. Kernel
Threads have somehow longer context switching time. Kernel helps in the
management of threads.
Types of Process
● Independent process
● Co-operating process
Methods of IPC
● Shared Memory
● Message Passing