INTRODUCTION TO IT
DWIT 120
CHAPTER 5
OPERATING SYSTEM AND
UTILITY PROGRAM
Introduction to computer
1
Operating System
• The computer system can be categorized mainly in four
components – hardware, operating system, application program,
and the user.
• Thehardware is responsible for providing various resources such
as memory and register or processing whenever the operating
system demands and the operating system will only demand
when the application programs that are developed by the
software engineer are running on the operating system asking
the operating system to demand from the hardware.
Operating System
OPERATING SYSTEM(OS)
• An operating system is an interface between user and computer hardware.
• Initially loaded into the computer by a boot program, launches and
manages all other application programs in a computer.
• it identifies and allocates hardware resources for the applications to
perform their tasks normally through API (Application Program Interface)
• The major operations of the operating system are
• process management
• memory management
• device management
• file management.
Operating System
Operating System
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, round
robin scheduling etc.
First Come First Served (FCFS)
• Advantages of FCFS:
• It is simple and easy to implement.
• Disadvantages of FCFS:
• Inefficient throughput
• If a process has a very high burst time and is coming first, then it will be
executed first even if another process with a lesser time is present in the
ready state.
Operating System
Process Management
• Shortest Job First (SJF )
Advantages:
• Short processes execute first.
• Disadvantages:
• There is a chance of starvation if short processes keep coming in
the ready state.
Operating System
Process Management
• Priority Scheduling
• Advantages:
• Higher priority processes execute first.
• Disadvantages:
• There is a chance of starvation if only higher priority processes
keep coming in the ready state
• If two processes have the same priorities, then some other
scheduling algorithm needs to be used.
Operating System
Process Management
• Shortest Remaining Time (SRT)
• Thisscheduling algorithm is the preemptive version of the SJN
algorithm. The OS allocates the processor to the job that is
closest to completion. Though there is a chance of this job being
preempted, if another job is ready with a shorter time to
completion.
• It
is used in batch environments where short jobs are given
preference and cannot be implemented in interactive systems
where required CPU time is unknown.
Operating System
Process Management
• Round Robin (RR)
• This scheduling algorithm is a preemptive process scheduling algorithm
where each process is provided a fixed time to execute. This fixed time is
called a quantum. It uses context switching to save states of preempted
processes. Once a process is done executing for a given time period, it is
preempted and another process executes for a given time period.
• Advantages:
• No starvation as every process gets a chance for its execution.
• Used in time-sharing systems.
• Disadvantages:
• The CPU is left idle due to a lot of context switching.
Operating System
Process Management
• There are many scheduling queues that are used to handle processes in
process management. When the processes enter the system, they are put
into the job queue. 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.
• The purpose of a scheduling algorithm is to provide:
• Maximum CPU utilization
• Minimum turnaround time
• Fair allocation of CPU
• Maximum throughput
• Minimum waiting time
• Minimum response time
Operating System
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 keeps track of
memory parts are in use by the processes and which are empty.
Operating System
Memory Management in summary
• Memory management keeps track of each and every memory
location
• It checks how much memory is to be allocated to processes.
• It decides which process will get memory at what time.
• It
deallocates memory from processes when a process has been
terminated or if it no longer needs the memory.
• It
tracks whenever some memory gets freed or unallocated and
correspondingly it updates the status.
Operating System
Memory Management
Contiguous and non contiguous
• Pros of Contiguous Memory Allocation
• 1. It supports a user’s random access to files.
• 2. The user gets excellent read performance.
• 3. It is fairly simple to implement.
• Cons of Contiguous Memory Allocation
• 1. Having a file grow might be somewhat difficult.
• 2. The disk may become fragmented.
Operating System
Memory Management
Contiguous and non contiguous
• There are two techniques for contiguous memory
allocation:
• Fixed Size Partitioning: Each process is allotted to a fixed size
continuous block in the main memory.
• Variable Size Partitioning: Each process is allotted space
depending upon its requirements. There is no defined fixed-size
block.
Operating System
Memory Management
• Different Placement Algorithm:
• 1. First Fit
• 2. Best Fit
• 3. Worst Fit
• 4. Next Fit
Operating System
Memory Management
• First Fit: In the first fit, the partition is allocated which is the
first sufficient block from the top of Main Memory. It scans
memory from the beginning and chooses the first available block
that is large enough. Thus it allocates the first hole that is large
enough.
Operating System
• Memory
Management
Operating System
Memory Management
• Best Fit Allocate the process to the partition which is the first
smallest sufficient partition among the free available partition.
• It
searches the entire list of holes to find the smallest hole whose
size is greater than or equal to the size of the process.
Operating System
• Memory
Management
Operating System
Memory Management
• Next Fit: Next fit is similar to the first fit but it will search for
the first sufficient partition from the last allocation point
• Is Best-Fit really best?
Although best fit minimizes the wastage space, it consumes a lot
of processor time for searching the block which is close to the
required size. Also, Best-fit may perform poorer than other
algorithms in some cases. For example
Operating System
Memory Management
• Exercise: Consider the requests from processes in given order
300K, 25K, 125K, and 50K. Let there be two blocks of memory
available of size 150K followed by a block size 350K.
• Which of the following partition allocation schemes can satisfy
the above requests?
A) Best fit but not first fit.
B) First fit but not best fit.
C) Both First fit & Best fit.
D) neither first fit nor best fit.
Operating System
Memory Management
• Solution: Let us try all options.
Best Fit:
300K is allocated from a block of size 350K. 50 is left in the block.
25K is allocated from the remaining 50K block. 25K is left in the block.
125K is allocated from 150 K block. 25K is left in this block also.
50K can’t be allocated even if there is 25K + 25K space available.
• FirstFit:
300K request is allocated from 350K block, 50K is left out.
25K is allocated from the 150K block, 125K is left out.
Then 125K and 50K are allocated to the remaining left out partitions.
So, the first fit can handle requests.
• So option B is the correct choice.
First Fit 150K
350K
300K
300K
25K 150K
125K 50K
25K
50K
125K
50K
125K
50K
50K
Best Fit 150K
350K
300K
300K
25K 150K
125K 50K
25K
50K
150K
25K
125K
25K
50K
25K
Operating System
Memory Management
• Fragmentation
• Fragmentation is defined as when the process is loaded and
removed after execution from memory, it creates a small free
hole. These holes can not be assigned to new processes because
holes are not combined or do not fulfill the memory requirement
of the process. To achieve a degree of multiprogramming, we
must reduce the waste of memory or fragmentation problems. In
the operating systems two types of fragmentation:
Operating System
Memory Management
• Internal Fragmentation
Internal fragmentation happens when the
memory is split into mounted-sized blocks.
Whenever a method is requested for the
memory, the mounted-sized block is allotted
to the method.
• In the case where the memory allotted to the
method is somewhat larger than the memory
requested, then the difference between
allotted and requested memory is called
internal fragmentation.
• We fixed the sizes of the memory blocks,
which has caused this issue. If we use
dynamic partitioning to allot space to the
process, this issue can be solved.
Operating System
Memory Management
• External Fragmentation
• External Fragmentation:
External fragmentation happens
when there’s a sufficient quantity of
area within the memory to satisfy
the memory request of a method.
• However, the process’s memory
request cannot be fulfilled because
the memory offered is in a non-
contiguous manner.
• Whether you apply a first-fit or best-
fit memory allocation strategy it’ll
cause external fragmentation.
Operating System
Device Management
• Thereare many I/O devices handled by the operating system
such as
• mouse,
• keyboard,
• disk drive etc.
• Thereare different device drivers that can be connected to the
operating system to handle a specific device.
• Theuser applications can access all the I/O devices using the
device drivers.
Operating System
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.
• 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.
Operating System
Views of the Operating System
• Theoperating system can be observed from the point of view of
the user or the system. This is known as the user view and
system view respectively. An operating system is a framework
that enables user application programs to interact with system
hardware.
• Theoperating system does not perform any functions on its own,
but it provides an atmosphere in which various programs and
apps can do useful work.
• Theoperating system may be observed from the point of view of
the user or the system, and it is known as the user view and the
system view.
Operating System
Viewpoints of the Operating System
There are mainly two types of views of the operating system.
• User view and System view
• User view − The user viewpoint focuses on how the user interacts
with the operating system through the usage of various application
programs. Some systems are designed for a single user to
monopolize the resources to maximize the user’s task. The
Operating system is designed primarily for ease of use, users
operate their computer system with the help of a monitor,
keyboard, mouse, printer, etc. The system is designed for
maximizing the work output by one user
• Less attention is paid to the performance of the operating system.
Operating System
• Smart phones with its touch screen gives the best handheld
technology ever
• It
is a great example of creating a device focused on the user’s
point of view
Operating System
Viewpoints of the Operating System
• System View
• systempoint of view sees the hardware has to interact with
the operating system for accomplishing the various tasks.
Operating System
• System view
• An operating system can also be considered as a program running at
all times in the background of a computer system known as the kernel
and handling all the application programs. The operating system 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 is
responsible for managing hardware resources and allocating them to
programs and users to ensure maximum performance. In the system
viewpoint the operating system is more involved with hardware
services -CPU time, memory space, I/O operation , and so on.
Operating System
Resource Allocation
• There are many resources which present in the hardware such as
register, cache, RAM, ROM, processors, I/O interaction, etc. These
resources demanded by the operating system when it is asked by any
application program.
• This
resource allocation has to be done only by the operating system
which has used many techniques and strategies such that it brings the
most out of its processing and memory space. There are various
techniques such as paging, virtual memory, caching, etc.
• The operating system allocates resources when a program needs
them. When the program terminates, the resources are unallocated
and allocated to other programs that need them.
Operating System
Resource Allocation
• Manyresources are present in the hardware such as register, cache,
RAM, ROM, processors, I/O interaction, etc.
• Theseare all resources that are demanded by the operating system
when it is asked by any application program.
• This
resource allocation has to be done only by the operating system
which has used many techniques and strategies such that it brings the
most out of its processing and memory space.
• There are various techniques such as paging, virtual memory, caching,
etc. that the operating system uses to make the best out of the
hardware resources. And these are especially needed in a multiple
user viewpoint because in that case the less resource allocation
efficiency can also affect the user viewpoint causing the lag or hang of
the user system, therefore decreasing the user experience.
Operating System
Control program
• In
the control programs it 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, The
operating system must also have proper communication, control,
detect, and handle such devices.
Operating System
• Conclusion
• Theuser viewpoint is all about how the user has to interact with
the operating system with the help of various application
programs for accomplishing various tasks.
• The system viewpoint is to maximize the performance. In this
viewpoint, the operating system is more involved with hardware
resources – CPU time, memory space, I/O operation, and so on
and allocating them to programs and users for maximum
performance.
THE END