0% found this document useful (0 votes)
23 views

OS NOTES - UNIT 1

Introduction To Operating System.

Uploaded by

ashirai8090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

OS NOTES - UNIT 1

Introduction To Operating System.

Uploaded by

ashirai8090
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 20

1

OPERATING SYSTEM – 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.

An Operating System (OS) is a collection of software that manages computer


hardware resources and provides common services for computer programs. The
operating system is the most important type of system software in a computer system.

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.

For more, refer to Functions of Operating System.

Objectives of Operating Systems


Let us now see some of the objectives of the operating system, which are mentioned
below.
● Convenient to use: One of the objectives is to make the computer system
more convenient to use in an efficient manner.
● User Friendly: To make the computer system more interactive with a more
convenient interface for the users.
4
● Easy Access: To provide easy access to users for using resources by acting as
an intermediary between the hardware and its users.
● Management of Resources: For managing the resources of a computer in a
better and faster way.
● Controls and Monitoring: By keeping track of who is using which resource,
granting resource requests, and mediating conflicting requests from different
programs and users.
● Fair Sharing of Resources: Providing efficient and fair sharing of resources
between the users and programs.

Types of Operating Systems

Batch-Processing Operating System


The batch-processing operating system was very popular in the 1970s. In batch
operating system the jobs were performed in batches. This means Jobs having similar
requirements are grouped and executed as a group to speed up processing. Users using
batch operating systems do not interact with the computer directly. Each user prepares
their job using an offline device for example a punch card and submits it to the
computer operator. Once the programmers have left their programs with the operator,
they sort the programs with similar needs into batches.

Time Sharing Operating System


A time-shared operating system uses CPU scheduling and multi-programming to
provide each user with a small portion of a shared computer at once. Each user has at
least one separate program in memory. A program is loaded into memory and
executes, it performs a short period of time either before completion or to complete
I/O. This short period of time during which the user gets the attention of the CPU is
known as time slice, time slot, or quantum. It is typically of the order of 10 to 100
milliseconds.

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.

Types of Distributed Systems


There are many models and architectures of distributed systems in use today. ●
Client-server systems: The most traditional and simple type of distributed
system, involves a multitude of networked computers that interact with a
central server for data storage, processing, or other common goal. ●
Peer-to-peer networks: They distribute workloads among hundreds or
thousands of computers all running the same software.
● Cell phone networks: It is an advanced distributed system, sharing
workloads among handsets, switching systems, and internet-based devices.

Real Time Operating System (RTOS) Real-time


operating systems (RTOS) are used in environments where a large number of events,
mostly external to the computer system, must be accepted and processed in a short
time or within certain deadlines. such applications are industrial control, telephone
switching equipment, flight control, and real-time simulations.
With an RTOS, the processing time is measured in tenths of seconds. This system is
time-bound and has a fixed deadline. The processing in this type of system must occur
within the specified constraints. Otherwise, This will lead to system failure.
Examples of real-time operating systems are airline traffic control systems, Command
Control Systems, airline reservation systems, Heart pacemakers, Network Multimedia
Systems, robots, etc.

Types of Real-Time Operating System


The real-time operating systems can be of 3 types –

Hard Real-Time Operating System


These operating systems guarantee that critical tasks are completed within a range of
time. For example, a robot is hired to weld a car body. If the robot welds too early or
too late, the car cannot be sold, so it is a hard real-time system that requires complete
car welding by the robot hardly on time., scientific experiments, medical imaging
8

systems, industrial control systems, weapon systems, robots, air traffic control
systems, etc.

Soft Real-Time Operating System


This operating system provides some relaxation in the time limit. For example –
Multimedia systems, digital audio systems, etc. Explicit, programmer-defined, and
controlled processes are encountered in real-time systems. A separate process is
changed by handling a single external event. The process is activated upon the
occurrence of the related event signaled by an interrupt.
Parallel System

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

Advantages of Parallel Systems:

● High Performance: Parallel systems can execute computationally intensive


tasks more quickly compared to single processor systems.
● Cost Effective: Parallel systems can be more cost-effective compared to
distributed systems, as they do not require additional hardware for
communication.
Multiprogramming Operating System
A multiprogramming operating system may run many programs on a single processor computer.
If one program must wait for an input/output transfer in a multiprogramming operating system,
the other programs are ready to use the CPU. As a result, various jobs may share CPU time.
However, the execution of their jobs is not defined to be at the same time period.

When a program is being performed, it is known as a "Task", "Process", and "Job".


Concurrent program executions improve system resource consumption and throughput as
compared to serial and batch processing systems.

10

types of the Multiprogramming Operating System


There are mainly two types of multiprogramming operating systems. These are as follows:

1. Multitasking Operating System

2. Multiuser Operating System

Multitasking Operating System

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.

Multiuser Operating System

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

● Pointer: It is a stack pointer that is required to be saved when the process is


switched from one state to another to retain the current position of the
process.
● Process state: It stores the respective state of the process.
● Process number: Every process is assigned a unique id known as process
ID or PID which stores the process identifier.
● Program counter: Program Counter stores the counter, which contains the
address of the next instruction that is to be executed for the process. ● Register:
Registers in the PCB, it is a data structure. When a processes is running and it’s
time slice expires, the current value of process specific registers would be
stored in the PCB and the process would be swapped out. When the process is
scheduled to be run, the register values is read from the
15

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.

What is the Cooperating Process?


There are various processes in a computer system, which can be either independent or
cooperating processes that operate in the operating system. It is considered independent when
any other processes operating on the system may not impact a process. Process-independent
processes don't share any data with other processes. On the other way, a collaborating process
may be affected by any other process executing on the system. A cooperating process shares data
with another.

Advantages of Cooperating Process in Operating


System
There are various advantages of cooperating process in the operating system. Some
advantages of the cooperating system are as follows:
1. Information Sharing
Cooperating processes can be used to share information between various processes. It
could involve having access to the same files. A technique is necessary so that the processes
may access the files concurrently.

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

Cooperating processes can be used to accomplish subtasks of a single task simultaneously.


It improves computation speed by allowing the task to be accomplished faster. Although, it
is only possible if the system contains several processing elements.

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.

Concurrent execution of cooperating processes needs systems that enable processes to


communicate and synchronize their actions.

Methods of Cooperating Process


Cooperating processes may coordinate with each other by sharing data or messages. The
methods are given below:

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,

Process P1 and P2 may cooperate by using messages to communicate. Thread in


Operating System
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.
What is Thread in Operating Systems?
18

In a process, a thread refers to a single sequential activity being executed. These


activities are also known as thread of execution or thread control. Now, any
operating system process can execute a thread. We can say that a process can
have multiple threads.

Types of Thread in Operating System


Threads are of two types. These are described below.
● User Level Thread
● Kernel Level Thread

1. User Level Threads

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.

Advantages of User-Level Threads


19

● Implementation of the User-Level Thread is easier than Kernel Level


Thread.
● Context Switch Time is less in User Level Thread.
● User-Level Thread is more efficient than Kernel-Level Thread. ● Because
of the presence of only Program Counter, Register Set, and Stack Space, it
has a simple representation.

Disadvantages of User-Level Threads

● There is a lack of coordination between Thread and Kernel.


● In case of a page fault, the whole process can be blocked.

2. Kernel Level Threads

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.

Advantages of Kernel-Level Threads

● It has up-to-date information on all threads.


● Applications that block frequency are to be handled by the Kernel Level
Threads.
● Whenever any process requires more time to process, Kernel-Level
Thread provides more time to it.

Disadvantages of Kernel-Level threads


20

● Kernel-Level Thread is slower than User-Level Thread.


● Implementation of this type of thread is a little more complex than a
user-level thread.

Difference between Process and Thread


The primary difference is that threads within the same process run in a shared
memory space, while processes run in separate memory spaces. Threads are not
independent of one another like processes are, and as a result, threads share with
other threads their code section, data section, and OS resources (like open files
and signals). But, like a process, a thread has its own program counter (PC),
register set, and stack space.

Inter Process Communication (IPC)


Processes can coordinate and interact with one another using a method called
inter-process communication (IPC) . Through facilitating process collaboration, it
significantly contributes to improving the effectiveness, modularity, and ease of
software systems.

Types of Process
● Independent process
● Co-operating process

An independent process is not affected by the execution of other processes while a


co-operating process can be affected by other executing processes. Though one
can think that those processes, which are running independently, will execute
very efficiently, in reality, there are many situations when cooperative nature can
be utilized for increasing computational speed, convenience, and modularity.
Inter-process communication (IPC) is a mechanism that allows processes to
communicate with each other and synchronize their actions. The communication
between these processes can be seen as a method of cooperation between them.
Processes can communicate with each other through both:
21

Methods of IPC
● Shared Memory
● Message Passing

You might also like