File2 Introduction To Os
File2 Introduction To Os
OPERATING SYSTEM
Unit-1
Introduction: Definition, Computer System Components , User View , System View And System
Goals , Batch Systems, Multi Programmed Systems, Time-Sharing Systems, Real-Time Systems,
System Components, Operating System Services.
Process: Process Concept, Process State Diagram Process Control Block, Process Scheduling-
Scheduling Queues, Scheduler, Cooperating Process, Inter-process Communication.
CPU Scheduling: Basic Concepts, Preemptive and Non-Preemeptive Scheduling, Scheduling
Criteria, Scheduling Algorithms-FCFS, Shortest Job First Priority Scheduling, Round Robin
Scheduling.
Unit-2
Process Synchronization: The Critical Section Problem, Solution For Critical Section Problem,
Bakery Algorithm, Semaphores-Meaning, Types of Semaphores, Synchronization Problems-
Bounded Buffer Problem, Readers-Writers Problem.
Deadlocks: Deadlock Characterization, Methods for Handling Deadlocks, Deadlock Prevention,
Deadlock Avoidance, Deadlock Detection, Recovery From Deadlock.
Unit-3
Memory Management: Introduction, Logical Versus Physical Address Space, Dynamic Loading,
Dynamic Linking, Swapping, Contiguous Allocation, Partitioned Memory Allocation, Paging, Virtual
Memory Management-Segmentation, Segmentation With Paging.
File System: File Concepts, File Attributes, File Operations, File Types, File Structure, Access
Methods, Directory structure, File-System Structure, Allocation Methods- Contiguous Allocation,
Linked Allocation and Indexed Allocation, FreeSpace Management.
Unit-4
Introduction to Unix System: The Unix Operating System, The UNIX architecture.
Shell Programming: Vi editor, shell types, shell command line processing, shell script features,
executing a shell script, system and user-defined variables, expr command, shell screen interface,
read and echo statement, command substitution, escape sequence characters, shell script arguments,
positional parameters, test command, file test, string test, numeric test.
Conditional Control Structures: if statement, case statement Looping Control Structure-while,
until, for, statements. Jumping Control Structures – break, continue, exit. Shell Programs covering
the above concepts.
1|Page
OPERATING SYSTEM -SEP
Introduction
An operating system act as an intermediary between the user of a computer and computer hardware.
The purpose of an operating system is to provide an environment in which a user can execute programs
in a convenient and efficient manner. An operating system is software that manages the computer
hardware.
Operating System
Definition of Operating System:
An Operating system is a program that controls the execution of application programs and acts
as an interface between the user of a computer and the computer hardware.
A more common definition is that the operating system is the one program running at all times
on the computer (usually called the kernel), with all else being applications programs.
An Operating system is concerned with the allocation of resources and services, such as
memory, processors, devices and information. The Operating System correspondingly includes
programs to manage these resources, such as a traffic controller, a scheduler, memory
management module, I/O programs, and a file system.
What is an Operating System Used for?
As a platform for Application programs: It provides a platform, on top of which, other
programs, called application programs can run.
Managing Input-Output unit: It also allows the computer to manage its own resources such
as memory, monitor, keyboard, printer, etc. Management of these resources is required for
effective and fair utilization.
Multitasking: It manages memory and allows multiple programs to run in their own space and
even communicate with each other through shared memory.
Manages memory and Files: It manages the computer’s main memory and second storage.
Additionally, it allows and deallocates memory to all tasks and applications.
Provides Security: It helps to maintain the system and applications safe through the
authorization process. Thus, the OS provides security to the 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.
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.
2|Page
OPERATING SYSTEM -SEP
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 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 error messages, and other
debugging and error-detecting methods.
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.
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.
3|Page
OPERATING SYSTEM -SEP
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.
Computer System Components
4|Page
OPERATING SYSTEM -SEP
1. User View
2. System View
User View
The user view depends on the system interface that is used by the users. Some systems are designed
for a single user to monopolize the resources to maximize the user's task. In these cases, the OS is
designed primarily for ease of use, with little emphasis on quality and none on resource utilization.
The user viewpoint focuses on how the user interacts with the operating system through the usage of
various application programs. In contrast, the system viewpoint focuses on how the hardware interacts
with the operating system to complete various tasks.
1. Single User View Point
Most computer users use a monitor, keyboard, mouse, printer, and other accessories to operate their
computer system. In some cases, the system is designed to maximize the output of a single user. As a
result, more attention is laid on accessibility, and resource allocation is less important. These systems
are much more designed for a single user experience and meet the needs of a single user, where the
performance is not given focus as the multiple user systems.
2. Multiple User View Point
Another example of user views in which the importance of user experience and performance is given
is when there is one mainframe computer and many users on their computers trying to interact with
their kernels over the mainframe to each other. In such circumstances, memory allocation by the CPU
must be done effectively to give a good user experience. The client-server architecture is another good
example where many clients may interact through a remote server, and the same constraints of effective
use of server resources may arise.
3. Handled User View Point
Moreover, the touchscreen era has given you the best handheld technology ever. Smartphones interact
via wireless devices to perform numerous operations, but they're not as efficient as a computer
interface, limiting their usefulness. However, their operating system is a great example of creating a
device focused on the user's point of view.
4. Embedded System User View Point
Some systems, like embedded systems that lack a user point of view. The remote control used to
turn on or off the tv is all part of an embedded system in which the electronic device communicates
with another program where the user viewpoint is limited and allows the user to engage with the
application.
System View
The OS may also be viewed as just a resource allocator. A computer system comprises various sources,
such as hardware and software, which must be managed effectively. The operating system manages the
resources, decides between competing demands, controls the program execution, etc. According to this
point of view, the operating system's purpose is to maximize performance. The operating system is
responsible for managing hardware resources and allocating them to programs and users to ensure
maximum performance.
5|Page
OPERATING SYSTEM -SEP
From the user point of view, we've discussed the numerous applications that require varying degrees
of user participation. However, we are more concerned with how the hardware interacts with the
operating system than with the user from a system viewpoint. The hardware and the operating system
interact for a variety of reasons, including:
1. Resource Allocation
The hardware contains several resources like registers, caches, RAM, ROM, CPUs, I/O interaction,
etc. These are all resources that the operating system needs when an application program demands
them. Only the operating system can allocate resources, and it has used several tactics and strategies to
maximize its processing and memory space. The operating system uses a variety of strategies to get
the most out of the hardware resources, including paging, virtual memory, caching, and so on. These
are very important in the case of various user viewpoints because inefficient resource allocation may
affect the user viewpoint, causing the user system to lag or hang, reducing the user experience.
2. Control Program
The control program controls how input and output devices (hardware) interact with the operating
system. The user may request an action that can only be done with I/O devices; in this case, the
operating system must also have proper communication, control, detect, and handle such devices.
6|Page
OPERATING SYSTEM -SEP
7|Page
OPERATING SYSTEM -SEP
For example, in a single-tasking system, the CPU is not used if the current program waits for
some input/output to finish.
The idea of multiprogramming is to assign CPUs to other processes while the current process might
not be finished. This has the below advantages.
1) The user gets the feeling that he/she can run multiple applications on a single CPU even if the CPU
is running one process at a time.
2) CPU is utilized better.
All modern operating systems like MS Windows, Linux, etc are multiprogramming operating systems.
Advantages of Multiprogramming
Increase the resource utilisation of a computer system.
Support multiple simultaneously interactive users (terminals).
Keeps multiple runnable jobs loaded in memory .
Increase the throughput of the system.
The waiting time for a program is reduced.
Improve system’s overall responsiveness.
Improve the reliability and stability of the system.
Make the system suitable for multitasking environments.
8|Page
OPERATING SYSTEM -SEP
Disadvantages of Multiprogramming
Prior knowledge of scheduling algorithms (An algorithm that decides which next process will
get hold of the CPU) is required.
If it has a large number of jobs, then long-term jobs will have to require a long wait.
Memory management is needed in the operating system because all types of tasks are stored in
the main memory.
Using multiprogramming up to a larger extent can cause a heat-up issue.
9|Page
OPERATING SYSTEM -SEP
10 | P a g e
OPERATING SYSTEM -SEP
11 | P a g e
OPERATING SYSTEM -SEP
A process can be suspended temporarily and the execution of another process can be taken up. A
suspended process can be restarted later. Before suspending a process, its details are saved in a table
called the process table so that it can be executed later on. An operating system supports two system
calls to manage processes Create and Kill –
Create a system call used to create a new process.
Kill system call used to delete an existing process.
Files Management
Files are used for long-term storage. Files are used for both input and output. Every operating
system provides a file management service. This file management service can also be treated as an
abstraction as it hides the information about the disks from the user. The operating system also
provides a system call for file management. The system call for file management includes:
File creation
File deletion
Read and Write operations
Files are stored in a directory. System calls provide to put a file in a directory or to remove a file
from a directory. Files in the system are protected to maintain the privacy of the user. Below shows
the Hierarchical File Structure directory.
12 | P a g e
OPERATING SYSTEM -SEP
Command Interpreter
There are several ways for users to interface with the operating system. One of the approaches to
user interaction with the operating system is through commands. Command interpreter provides
a command-line interface. It allows the user to enter a command on the command line prompt
(cmd). The command interpreter accepts and executes the commands entered by a user. For
example, a shell is a command interpreter under UNIX. The commands to be executed are
implemented in two ways:
The command interpreter itself contains code to be executed.
The command is implemented through a system file. The necessary system file is loaded into
memory and executed.
System Calls
System calls provide an interface to the services made by an operating system. The user interacts
with the operating system programs through System calls. These calls are normally made available
as library functions in high-level languages such as C, Java, Python etc. It provides a level of
abstraction as the user is not aware of the implementation or execution of the call made. Details of
the operating system is hidden from the user. Different hardware and software services can be
availed through system calls.
System calls are available for the following operations:
Process Management
Memory Management
File Operations
Input / Output Operations
Signals
Signals are used in the operating systems to notify a process that a particular event has occurred.
Signals are the software or hardware interrupts that suspend the current execution of the task.
Signals are also used for inter-process communication. A signal follows the following pattern :
A signal is generated by the occurrence of a particular event it can be the clicking of the mouse,
the execution of the program successfully or an error notifying, etc.
A generated signal is delivered to a process for further execution.
Once delivered, the signal must be handled.
A signal can be synchronous and asynchronous which is handled by a default handler or by the
user-defined handler.
The signal causes temporarily suspends the current task it was processing, saves its registers on the
stack, and starts running a special signal handling procedure, where the signal is assigned to it.
Network Management
The complexity of networks and services has created modern challenges for IT professionals and
users. Network management is a set of processes and procedures that help organizations to optimize
13 | P a g e
OPERATING SYSTEM -SEP
their computer networks. Mainly, it ensures that users have the best possible experience while using
network applications and services.
Network management is a fundamental concept of computer networks. Network Management
Systems is a software application that provides network administrators with information on
components in their networks. It ensures the quality of service and availability of network
resources. It also examines the operations of a network, reconstructs its network configuration,
modifies it for improving performance of tasks.
Security Management
The security mechanisms in an operating system ensure that authorized programs have access to
resources, and unauthorized programs have no access to restricted resources. Security management
refers to the various processes where the user changes the file, memory, CPU, and other hardware
resources that should have authorization from the operating system.
I/O Device Management
The I/O device management component is an I/O manager that hides the details of hardware devices
and manages the main memory for devices using cache and spooling. This component provides a
buffer cache and general device driver code that allows the system to manage the main memory
and the hardware devices connected to it. It also provides and manages custom drivers for particular
hardware devices.
The purpose of the I/O system is to hide the details of hardware devices from the application
programmer. An I/O device management component allows highly efficient resource utilization
while minimizing errors and making programming easy on the entire range of devices available in
their systems.
Secondary Storage Management
Broadly, the secondary storage area is any space, where data is stored permanently and the user can
retrieve it easily. Your computer’s hard drive is the primary location for your files and programs.
Other spaces, such as CD-ROM/DVD drives, flash memory cards, and networked devices, also
provide secondary storage for data on the computer. The computer’s main memory (RAM) is a
volatile storage device in which all programs reside, it provides only temporary storage space for
performing tasks. Secondary storage refers to the media devices other than RAM (e.g. CDs, DVDs,
or hard disks) that provide additional space for permanent storing of data and software programs
which is also called non-volatile storage.
Main Memory Management
Main memory is a flexible and volatile type of storage device. It is a large sequence of bytes and
addresses used to store volatile data. Main memory is also called Random Access Memory (RAM),
which is the fastest computer storage available on PCs. It is costly and low in terms of storage as
compared to secondary storage devices. Whenever computer programs are executed, it is
temporarily stored in the main memory for execution. Later, the user can permanently store the data
or program in the secondary storage device.
14 | P a g e
OPERATING SYSTEM -SEP
15 | P a g e
OPERATING SYSTEM -SEP
Memory Management
Let’s understand memory management by OS in simple way. Imagine a cricket team with limited
number of player. The team manager (OS) decide whether the upcoming player will be in playing 11
,playing 15 or will not be included in team , based on his performance . In the same way, OS first check
whether the upcoming program fulfil all requirement to get memory space or not, if all things good, it
checks how much memory space will be sufficient for program and then load the program into memory
at certain location. And thus, it prevents program from using unnecessary memory.
Process Management
Let’s understand the process management in unique way. Imagine, our kitchen stove as the (CPU)
where all cooking(execution) is really happen and chef as the (OS) who uses kitchen-stove(CPU) to
cook different dishes(program). The chef(OS) has to cook different dishes(programs) so he ensure that
any particular dish(program) does not take long time (unnecessary time) and all dishes(programs) gets
a chance to cooked(execution). The chef(OS) basically scheduled time for all dishes(programs) to run
kitchen(all the system) smoothly and thus cooked(execute) all the different dishes(programs)
efficiently.
Security and Privacy
Security: OS keep our computer safe from an unauthorized user by adding security layer to it.
Basically, Security is nothing but just a layer of protection which protect computer from bad
guys like viruses and hackers. OS provide us defenses like firewalls and anti-virus software and
ensure good safety of computer and personal information.
Privacy: OS give us facility to keep our essential information hidden like having a lock on our
door, where only you can enter and other are not allowed. Basically, it respect our secrets and
provide us facility to keep it safe.
Resource Management
System resources are shared between various processes. It is the Operating system that manages
resource sharing. It also manages the CPU time among processes using CPU Scheduling Algorithms.
It also helps in the memory management of the system. It also controls input-output devices. The OS
also ensures the proper use of all the resources available by deciding which resource to be used by
whom.
User Interface
User interface is essential and all operating systems provide it. Users either interacts with the operating
system through the command-line interface or graphical user interface or GUI. The command
interpreter executes the next user-specified command.
A GUI offers the user a mouse-based window and menu system as an interface.
Networking
This service enables communication between devices on a network, such as connecting to the internet,
sending and receiving data packets, and managing network connections.
Error Handling
The Operating System also handles the error occurring in the CPU, in Input-Output devices, etc. It also
ensures that an error does not occur frequently and fixes the errors. It also prevents the process from
16 | P a g e
OPERATING SYSTEM -SEP
coming to a deadlock. It also looks for any type of error or bugs that can occur while any task. The
well-secured OS sometimes also acts as a countermeasure for preventing any sort of breach of the
Computer System from any external source and probably handling them.
Time Management
Imagine traffic light as (OS), which indicates all the cars(programs) whether it should be
stop(red)=>(simple queue), start(yellow)=>(ready queue), move(green)=>(under execution) and this
light (control) changes after a certain interval of time at each side of the road(computer system) so that
the cars(program) from all side of road move smoothly without traffic.
17 | P a g e