You are on page 1of 28

Page |1

Practical File
Operating System Lab
BCA-401P

Bachelor of Computer Application (IVth)


Session- 2022-23

Submitted To Submitted By
Mr. Dhanish Tandon SUYASH SHARMA
ASSOCIATE PROFESSOR Roll No-220031150040

RBMI Group of Institutions, Bareilly


(Affiliated to M.J.P. Rohilkhand University, Bareilly)

220031150040 SUYASH SHARMA


Page |2

INDEX

S.no. Practical Name Page no.

1. Internal and External DOS Com- 3-10


mands.

Study of Hardware and Software


2. requirementsof different operating 11-16
systems (UNIX, LINUX, WINDOW
7,WINDOWS 10/11.)

Execute various UNIX system calls


3. for
A) Process management
B) File management 17-19
C) Input/output system
calls.
Implement CPU Scheduling Poli-
4. cies:
A) SJF 20-24
B) FCFS

Implement CPU Scheduling Policies


5. :
A) Priority 25-28
B) Round Robin

220031150040 SUYASH SHARMA


Page |3

INTERNAL AND EXTERNAL COMMANDS IN MS-DOS

MS-DOS Internal Command


Internal commands in MS-DOS are commands that are built into the
command interpreter itself. These commands are available directly from
the command prompt without the need for external executable files. Here
are some commonly used internal commands in MS-DOS:

1. MD COMMAND (Make Directory) - MD command is used to create a


new directory or subdirectory in the Disk.
Syntax–
C:\>md (directory name)
Example-
c:\> md SUYASH

2. CLS COMMAND (Clear) - CLS is one of the internal DOS commands


that is used to clear the DOS screen. If you can clear whatever command
you run on the screen through the CLS command.
Syntax-
C:\>cls

( this) ( to this )

3. CD COMMAND (Change Directory) - CD is an internal dos command


used to change the directory (to insider or come out). If you want to go
from one directory to another, then you can go with the CD command.
Syntax–
C:\>cd (Directory name)
220031150040 SUYASH SHARMA
Page |4

Example-
C:\cd SUYASH

4. COPY CON COMMAND - COPY CON command is used to basically


create a file. The only disadvantage of the command is that the created
by COPY CON command cannot be modified.
Syntax-
C:\copy con (file name with extension)
Example-
C:\copy con sharma.txt

5. COPY COMMAND - The COPY command is used to copy the file and
move the file to another location or folder or drive.
Syntax-
C: \> Copy <File Name><New Name>
C: \> Copy <Path File Name><Target Drive>
Example-
C:> Copy C:\ABC*.* D:\sonu and Press enter.

6. DATE COMMAND - The Date command is used to view the system’s


current date. if you want to modify the date then you can easily do it
from the date command.
Syntax-
C: \> date
Example-

220031150040 SUYASH SHARMA


Page |5

C:\>date
The current date is: 10/12/2021
Enter the new date: (dd-mm-yy) 09/12/2021

7. TIME COMMAND - The time command is used to view the system’s


current date. if you want to modify the date then you can easily do it
from the time command.
Syntax-
C: \>time
Example-
C:>time
The current time is: 23:23:27.63
Enter the new time: 23:25:50.43

8. DEL COMMAND - A DEL command is used to remove a file from the


disk. To delete any files or directory from any drive you would define the
path and folder.
SYNTAX-
C:\> Del (file name) delete only one file.
C:\>ABC Del *.* delete all files from ABC folder.

9. RD or RMDIR - RD or RMDIR command is used to remove a particular


directory or subdirectory from the disk. Only an empty directory or
subdirectory can be removed.
Syntax-
220031150040 SUYASH SHARMA
Page |6

C: \> RD <DIR name>


Example-
C: \> RD SUYASH

10. REN COMMAND - A REN command is basically used to change the


name of an existing file or folder. If you want to change any folder name
by the REN command you can easily change the folder name. Syntax and
example are as below-
Syntax-
C: \> REN <Old File Name><New File Name>
Example-
C: > REN SUYASH Suyash

11. TYPE COMMAND - Type command is an internal command used to


view the content of any file. If you want to see what is saved in that file
then you can see by type command.
Syntax-
C:\ > TYPE <DIR name>
EXAMPLE-
C: > TYPE bajetha.txt

220031150040 SUYASH SHARMA


Page |7

12. VER COMMAND - If you want to see your Windows Operating


system then you can see the version information by the VER command.
Follow the syntax and example are below-
Syntax-
C:>ver

13. MOVE COMMAND - The move is an internal command used to


change the name of any directory. Follow the syntax and example are
below-
Syntax-
C:/> move old dir(name) new dir (name)
C:/> move AbhiSUYASH

14. COLOR COMMAND - The COLOR command is used to change the


default color of the background. IF you want to change the default
background color of the DOS or Windows command line, from the use of
color command you can easily change.
The color attributes are as follow-

0- Black 8- Gray

1- Blue 9- Light Blue

2-Green A- Light Green

3-Aqua B- Light Aqua

4- Red C- Light Red

5- Purple D- Light Purple

6- Yellow E- Light Yellow

220031150040 SUYASH SHARMA


Page |8

7- White F- Bright White

Syntax-
color (attribute)
Example-
C:\Users\SUYASH>color a

220031150040 SUYASH SHARMA


Page |9

MS-DOS External Commands


External commands in the context of operating systems refer to commands
that are not directly built into the command interpreter (shell) or the operating
system kernel. These commands are separate executable files stored in specific
directories that can be accessed and executed from the command prompt or
shell. Here are some of the most commonly used external commands in MS-
DOS, along with their syntax:

1. FORMAT:
Syntax: FORMAT [drive:] [/V:label] [/Q] [/F:size] [/S] [/U] [/C]
Explanation: Formats a disk or drive.

2. CHKDSK:
Syntax: CHKDSK [drive:] [/F] [/R]
Explanation: Checks a disk for errors and attempts to fix them.

3. DISKCOPY:
Syntax: DISKCOPY [drive1: [drive2:]] [/V] [/B]
Explanation: Copies the entire contents of one disk to another.

4. ATTRIB:
Syntax: ATTRIB [+R|-R] [+A|-A] [+S|-S] [+H|-H] [drive:][path][filename]
Explanation: Modifies file attributes such as Read-only, Archive, System, and
Hidden.

5. XCOPY:
Syntax: XCOPY source [destination] [/E] [/S] [/V] [/P] [/Q]
Explanation: Copies files and directories, including subdirectories.

6. EDIT:
Syntax: EDIT [filename]
Explanation: Opens a simple text editor.

7. DEBUG:
Syntax: DEBUG
Explanation: A debugging tool that allows low-level programming and editing
of binary files.

8. TREE:
Syntax: TREE [drive:][path]
Explanation: Displays a graphical representation of the directory structure.

9. FDISK:
Syntax: FDISK
220031150040 SUYASH SHARMA
P a g e | 10

Explanation: A disk partitioning utility.

10. DELTREE:
Syntax: DELTREE [/Y] [drive:][path]
Explanation: Deletes a directory and all its contents.

11. MOVE:
Syntax: MOVE [drive:][path]filename1 [drive:][path]filename2
Explanation: Moves a file from one location to another.

12. FIND:
Syntax: FIND "string" [drive:][path]filename
Explanation: Searches for a specific string in a file or set of files.

13. SORT:
Syntax: SORT [drive:][path]filename [/O outputfile]
Explanation: Sorts the contents of a text file and displays the result or saves it
to another file.

14. COMP:
Syntax: COMP [drive1:][path1]filename1 [drive2:][path2]filename2 [/A] [/L]
Explanation: Compares the contents of two files byte by byte.

15. FC:
Syntax: FC [drive1:][path1]filename1 [drive2:][path2]filename2 [/A] [/L] [/N]
[/C]
Explanation: Compares two files or sets of files and displays the differences
between them.

These commands cover a range of operations including disk management, file


manipulation, and text processing, and are frequently used in MS-DOS
environments.

220031150040 SUYASH SHARMA


P a g e | 11

Hardware and software requirements for


UNIX OS
The hardware and software requirements for a UNIX operating system can vary
depending on the specific distribution and version of UNIX you are considering.
However, here are some general guidelines:

Hardware Requirements:

1. Processor: Most UNIX distributions support a wide range of processors,


including x86, x86-64, ARM, SPARC, and PowerPC.

2. Memory (RAM): The minimum RAM requirement varies, but typically a UNIX
system can run with 512 MB to 1 GB of RAM. However, for better performance
and to accommodate more processes, it is recommended to have at least 2-4
GB of RAM.

3. Storage: UNIX distributions generally require a minimum of several


gigabytes of disk space for the installation. The actual disk space required will
depend on the specific distribution and the software packages you choose to
install.
4. Network Interface: A network interface card (NIC) is required if you want to
connect your UNIX system to a network.

Software Requirements:

1. UNIX Distribution: Choose a specific UNIX distribution based on your needs


and preferences. Some popular UNIX distributions include Linux (e.g., Ubuntu,
Fedora, CentOS), BSD (e.g., FreeBSD, Open BSD), and Solaris.

2. Boot Loader: The UNIX distribution will typically come with a boot loader,
such as GRUB or LILO, which allows you to select the operating system to boot
when you start your computer.

3. File System: UNIX supports various file systems, including ext4, XFS, ZFS,
and UFS. The specific file system you use will depend on the UNIX distribution
and your requirements.

4. Graphical Environment (Optional): If you prefer a graphical user interface


(GUI), you may need to install a desktop environment, such as GNOME or KDE,
along with the required display drivers.

These are general requirements, and it's important to consult the


documentation or system requirements specific to the UNIX distribution you
plan to use. Different UNIX distribution may have additional or slightly different
hardware and software requirements.

220031150040 SUYASH SHARMA


P a g e | 12

Hardware and software requirements for


LINUX OS
Linux is a UNIX-like operating system, and the hardware and software
requirements for Linux distributions can vary depending on the specific
distribution and version you choose. Here are some general guidelines:

Hardware Requirements:
Processor: Linux supports a wide range of processors, including x86, x86-64, ARM,
SPARC, and PowerPC. The specific requirements will depend on the distribution and
the software packages you plan to use.

Memory (RAM): The minimum RAM requirement varies, but most Linux distributions
can run with 1 GB to 2 GB of RAM. However, for smoother performance and to
accommodate more demanding applications, it is recommended to have at least 4 GB
of RAM.

Storage: Linux distributions typically require several gigabytes of disk space for
installation. The actual disk space needed will depend on the distribution and the
software packages you choose to install. A minimum of 10-20 GB of disk space is
generally recommended.

Network Interface: A network interface card (NIC) is required if you want to connect
your Linux system to a network.

Software Requirements:
Linux Distribution: Choose a specific Linux distribution based on your needs and
preferences. Some popular Linux distributions include Ubuntu, Fedora, CentOS,
DEBIAN, and Linux Mint. Each distribution has its own hardware and software
requirements, so it's important to consult the specific documentation for the
distribution you choose.

Boot Loader: Linux distributions typically come with a boot loader, such as GRUB or
LILO, which allows you to select the operating system to boot when you start your
computer.

File System: Linux supports various file systems, including ext4, XFS, and BTRFs. The
specific file system you use will depend on the distribution and your requirements.

Graphical Environment (Optional): If you prefer a graphical user interface (GUI), you
may need to install a desktop environment, such as GNOME, KDE, or XFCE, along
with the required display drivers.

Again, it's important to note that these are general requirements, and the specific
hardware and software requirements can vary depending on the Linux distribution
you choose and the intended use of your system. Always refer to the documentation
or system requirements provided by the specific Linux distribution for accurate and
up-to-date information.

220031150040 SUYASH SHARMA


P a g e | 13

Hardware and software requirements for


WINDOWS 7
The following are the recommended hardware and software requirements for
Windows 7:

Hardware Requirements

1. Processor: 1 GHz or faster processor (32-bit or 64-bit)


2. Memory (RAM): 1 GB RAM for 32-bit systems or 2 GB RAM for 64-bit
systems
3. Storage: 16 GB of available hard disk space for 32-bit systems or 20 GB for
64-bit systems
4. Graphics: DirectX 9 graphics device with WDDM 1.0 or higher driver.

Software Requirements
1. Operating System: Windows 7 is the operating system itself.
2. Display: A monitor capable of at least 800x600 resolution (higher resolutions
are recommended)
3. Internet Connection: Some features of Windows 7, such as Windows Update,
require an internet connection.
4. Optional: DVD/CD drive if you plan to install Windows 7 from a disc.

It's important to note that these are the minimum recommended requirements,
and for optimal performance, it's often beneficial to have more powerful
hardware, such as a faster processor, more RAM, and a larger hard disk space.
Additionally, some software applications or games may have their own specific
requirements that go beyond the minimum system requirements of Windows 7.

220031150040 SUYASH SHARMA


P a g e | 14

Hardware and software requirements for


WINDOWS 10
The following are the recommended hardware and software requirements for
Windows 10:

Hardware Requirements:
1. Processor: 1 GHz or faster processor with at least 2 cores (64-bit)
2. Memory (RAM): 4 GB RAM or more
3. Storage: 64 GB of available hard disk space or more
4. Graphics: DirectX 9 or later with WDDM 2.0 driver
5. Display: A monitor capable of at least 800x600 resolution (higher resolutions
are recommended).

Software Requirements:
1. Operating System: Windows 10 is the operating system itself.
2. Internet Connection: Some features of Windows 10, such as Windows
Update and online services, require an internet connection.
3. Microsoft Account: While not mandatory, having a Microsoft account can
enable access to additional features and cloud-based services.

It's important to note that these are the recommended requirements, and the
actual hardware and software requirements may vary depending on the
specific usage scenario and software applications you intend to run. Certain
resource-intensive applications or games may have their own specific
requirements beyond the minimum system requirements of Windows 10

220031150040 SUYASH SHARMA


P a g e | 15

Hardware and software requirements for


WINDOWS 11
The following are the recommended hardware and software requirements for
Windows 11:

Hardware Requirements:
1. Processor: 1 GHz or faster with at least 2 cores on a 64-bit compatible
processor.
2. Memory (RAM): 4 GB RAM or more.
3. Storage: 64 GB of available storage or more.
4. System Firmware: UEFI firmware with Secure Boot capability.
5. TPM Version: TPM version 2.0.
6. Graphics: DirectX 12 or later with a WDDM 2.0 driver.
7. Display: A high-definition (720p) display, 9" or larger diagonally, with 8 bits
per color channel.

Software Requirements:
1. Operating System: Windows 11 is the operating system itself.
2. Internet Connection: Some features and updates in Windows 11 require an
internet connection.
3. Microsoft Account: While not mandatory, having a Microsoft account can
enable access to additional features and cloud-based services.

It's important to note that Windows 11 introduces stricter hardware


requirements compared to previous versions of Windows. The TPM 2.0
requirement and specific processor, storage, and display specifications need to
be met for the installation and proper functioning of Windows 11. Additionally,
not all existing hardware that meets Windows 10 requirements may be
compatible with Windows 11. Microsoft provides a PC Health Check tool that
can help determine if your system meets the requirements for Windows 11

220031150040 SUYASH SHARMA


P a g e | 16

System Calls in Operating System (OS)


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 or a high-level language like C or Pascal.
System calls are predefined functions that the operating system may directly
invoke if a high-level language is used.

In this article, you will learn about the system calls in the operating system
and discuss their types and many other things.

What is a System Call?

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 Application Program Interface (API) connects the operating system's


functions to user programs. It acts as a link between the operating system and
a process, allowing user-level programs to request operating system services.
The kernel system can only be accessed using system calls. System calls are
required for any programs that use resources.

220031150040 SUYASH SHARMA


P a g e | 17

UNIX System calls for Process management

A system is used to create a new process or a duplicate process called a fork.


The duplicate process consists of all data in the file description and registers
common. The original process is also called the parent process and the
duplicate is called the child process.
The fork call returns a value, which is zero in the child and equal to the child’s
PID (Process Identifier) in the parent. The system calls like exit would request
the services for terminating a process.
Loading of programs or changing of the original image with duplicate needs
execution of exec. PID would help to distinguish between child and parent
processes.

Here are some common Unix system calls for process management:

fork(): Creates a new process by duplicating the existing process. It returns


twice: once in the parent process (with the process ID of the child) and once in
the child process (with a return value of 0).

exec() family: Replaces the current process with a new process image.

Execve(const char *path, char *constargv[], char *constenvp[]) : Loads and


executes a new program from the given file path, with the specified command-
line arguments and environment variables.

execl(const char *path, const char *arg0, ..., const char *argn, (char *)
NULL): Executes a new program from the given file path with a variable
number of command-line arguments.

wait() and waitpid(): Used to wait for the termination of child processes.

wait(int *status): Suspends the current process until one of its child processes
terminates. It can retrieve the termination status of the child process.

waitpid(pid_tpid, int *status, int options): Suspends the current process until
the child process with the specified process ID terminates.

exit(): Terminates the current process and returns the exit status to the
parent process.

getpid(): Returns the process ID of the current process.

220031150040 SUYASH SHARMA


P a g e | 18

UNIX system calls for File Management


File management is a system call that is used to handle the files. Some file
management examples include creating files, delete files, open, close, read,
write, etc.

several Unix system calls commonly used for file management:

open(const char *path, int flags, mode_t mode): Opens a file specified by the
file path, with specified flags indicating the file's intended use (e.g., read,
write, create, etc.) and the file mode (permissions) if the file is being created.

close(intfd): Closes the file descriptor fd that was previously opened.

read(intfd, void *buf, size_t count): Reads data from the file associated with
the file descriptor fd into the buffer buf of size count.

write(intfd, const void *buf, size_t count): Writes data from the buffer buf of
size count to the file associated with the file descriptor fd.

lseek(intfd, off_t offset, int whence): Changes the file offset (position) of the
file associated with the file descriptor fd. The whence parameter specifies how
the offset is calculated (e.g., from the beginning, current position, or end of
the file).

unlink(const char *path): Deletes (unlinks) the file specified by the file path.

rename(const char *oldpath, const char *newpath): Renames a file, changing


its name from oldpath to newpath.

chmod(const char *path, mode_t mode): Changes the permissions of a file


specified by the file path to the specified mode.

220031150040 SUYASH SHARMA


P a g e | 19

UNIX system calls for input/output


The following are the UNIX system calls for I/O:

-Open: to open a file


Syntax:
open (pathname, flag, and mode).
- Create: To create a file.
Syntax:
create (pathname, mode).
- Close: To close a file.
Syntax:
close (filedes).
- Read: To read data from a file that is opened.
Syntax:
read (filedes, buffer, bytes)

- Write: To write data to a file that is opened.


Syntax:
write (filedes, buffer, bytes)
- Lseek: To position the file pointer at given location in the file.
Syntax:
lseek (filedes, offset, from).
- Dup: To make a duplicate copy of an existing file descriptor.

Syntax:
dup (filedes).

220031150040 SUYASH SHARMA


P a g e | 20

CPU Scheduling policies


A CPU Scheduling is a set of rules and objectives that guides the schedule optimizer
in its decisions. It means Scheduling of processes/work is done to finish the work on
time. CPU Scheduling is a process that allows one process to use the CPU while
another process is delayed (in standby) due to unavailability of any resources such as
I/O etc , thus making full use of the CPU. The purpose of CPU Scheduling is to make
the system more efficient, faster, and fairer.
Whenever the CPU becomes idle, the operating system must select one of the
processes in the done by a temporary (CPU) scheduler. The scheduler selects
between memory processes ready to launch and assigns the cpu to one of them.

Types of CPU Scheduling


CPU Scheduling decision place until the following four criteria -
1. When a process switches from running state to waiting state.
2. Process switching from running state to ready.
3. Process switching from read state to ready state.
4. When the process communicate.

 There are two types of CPU scheduling.


1. Pre-emptive scheduling
2. 2. Non pre-emptive scheduling

1. Pre-emptive scheduling : The CPU have been allocated to a certain


process it can be snatched from this process any time either due to
time constant or due to priority reasons. It employee that if the
process is with higher priority become ready for execution. The process
which is currently using the CPU will be forced to give up the CPU so
that higher priority job can run first.

2. Non pre-emptive scheduling :- Once the CPU has been allocated to


a process the process keep the CPU until it’s termination or it’s
transaction to the block state. This mean’s that once CPU is allocated
to a process this process this process can use the CPU for it’s own
execution until it billing the surrender or leaves the CPU.

220031150040 SUYASH SHARMA


P a g e | 21

Shortest Job First CPU Scheduling(SJF)


Shortest Job First is a scheduling process that selects the waiting process with
the smallest execution time to execute next. This scheduling method may or
may not be pre-emptive. Significantly reduces the average waiting time for
other processes waiting to be executed. The full form of SJF is Shortest Job
First.

Characteristics of SJF:

 Shortest Job first has the advantage of having a minimum average


waiting time among all operating system scheduling algorithm
 It is associated with each task as a unit of time to complete.
 It may cause starvation if shorter processes keep coming. This
problem can be solved using the concept of ageing.

Advantages of Shortest Job first:

 As SJF reduces the average waiting time thus, it is better than the
first come first serve scheduling algorithm.
 SJF is generally used for long term scheduling

Disadvantages of SJF:

 One of the demerit SJF has is starvation.


 Many times it becomes complicated to predict the length of the
upcoming CPU request
To learn about how to implement this CPU scheduling algorithm, please refer
to our detailed article on Shortest Job First.

Problem :- Consider the set of 5 processes whose arrival timeand burst time
are given below-

220031150040 SUYASH SHARMA


P a g e | 22

If the CPU scheduling policy is SJF pre-emptive, calculate the average waiting
time and average turnaround time.
Solution-
 Gantt Chart-

Now, we know-
• Turn Around time = Exit time – Arrival time
• Waiting time = Turn Around time – Burst time

Now,
• Average Turn Around time = (1 + 5 + 4 + 16 + 9) / 5
= 35 / 5
= 7 unit
• Average waiting time = (0 + 1 + 2 + 10 + 6) / 5
= 19 / 5
= 3.8 unit

220031150040 SUYASH SHARMA


P a g e | 23

First Come First Serve


FCFS considered to be the simplest of all operating system scheduling algorithms.
First come first serve scheduling algorithm states that the process that requests the
CPU first is allocated the CPU first and is implemented by using FIFO Queue.

Characteristics of FCFS:
 FCFS supports non-preemptive and pre-emptive CPU scheduling algorithms.
 Tasks are always executed on a First-come, First-serve concept.
 FCFS is easy to implement and use.
 This algorithm is not much efficient in performance, and the wait time is
quite high.

Advantages of FCFS:
 Easy to implement
 First come, first serve method

Disadvantages of FCFS:
 FCFS suffers from Convoy effect.
 The average waiting time is much higher than the other algorithms.
 FCFS is very simple and easy to implement and hence not much efficient.

Convoy Effect
• In convoy effect, Consider processes with higher burst time arrived before the
processes with smaller burst time.
• Then, smaller processes have to wait for a long time for longer processes to
release the CPU.

Problem-Consider the set of 6 processes whose arrival time and burst time are given
below-

If the CPU scheduling policy is FCFS and there is 1 unit of overhead in scheduling the
processes, find the efficiency of the algorithm.
Solution-

220031150040 SUYASH SHARMA


P a g e | 24

 Gantt Chart-

Here, δ denotes the context switching overhead


Now,
Useless time / Wasted time = 6 x δ = 6 x 1 = 6 unit
Total time = 23 unit
Useful time = 23 unit – 6 unit = 17 unit
Efficiency (η)= Useful time / Total Total
= 17 unit / 23 unit
= 0.7391
= 73.91%

220031150040 SUYASH SHARMA


P a g e | 25

Priority Scheduling
Pre-emptive Priority CPU Scheduling Algorithm is a pre-emptive method of CPU Scheduling
algorithm that works based on the priority of a process. In this algorithm, the editor sets
the functions to be as important, meaning that the most important process must be done
first. In the case of any conflict, that is, where there are more than one processor with
equal value, then the most important CPU planning algorithm works on the basis of the
FCFS (First Come First Serve) algorithm.

Characteristics of Priority Scheduling:


 Schedules tasks based on priority.
 When the higher priority work arrives while a task with less priority is executed,
the higher priority work takes the place of the less priority one and
 The latter is suspended until the execution is complete.
 Lower is the number assigned, higher is the priority level of a process.

Advantages of Priority Scheduling:


 The average waiting time is less than FCFS
 Less complex

Disadvantages of Priority Scheduling:


 One of the most common demerits of the Pre-emptive priority CPU scheduling
algorithm is the Starvation Problem. This is the problem in which a process has to
wait for a longer amount of time to get scheduled into the CPU. This condition is
called the starvation problem.

Problem :- Consider the set of 5 processes whose arrival time and burst time are given
below-

If the CPU scheduling policy is priority preemptive, calculate the average waiting time and
average turn around time. (Higher number represents higher priority)

Solution-

 Gantt Chart-

220031150040 SUYASH SHARMA


P a g e | 26

Now, we know-
• Turn Around time = Exit time – Arrival time
• Waiting time = Turn Around time – Burst time

• Average Turn Around time = (15 + 11 + 1 + 5 + 6) / 5


= 38 / 5
= 7.6 unit
• Average waiting time = (11 + 8 + 0 + 0 + 4) / 5
= 23 / 5
= 4.6 unit

220031150040 SUYASH SHARMA


P a g e | 27

Round Robin
Round Robin is a CPU scheduling algorithm where each process is cyclically assigned
a fixed time slot. It is the pre-emptive version of First come First serve CPU
Scheduling algorithm. Round Robin CPU Algorithm generally focuses on Time
Sharing technique.

Characteristics of Round robin:


 It’s simple, easy to use, and starvation-free as all processes get the
balanced CPU allocation.
 One of the most widely used methods in CPU scheduling as a core.
 It is considered pre-emptive as the processes are given to the CPU for a
very limited time.

Advantages of Round robin:


 Round robin seems to be fair as every process gets an equal share of CPU.
 The newly created process is added to the end of the ready queue.

Problem :-Consider the set of 6 processes whose arrival time and burst time are
given below-

If the CPU scheduling policy is Round Robin with time quantum = 2, calculate the
average waiting time and average turnaround time.
Solution :-
 Gantt Chart-
 Ready Queue- P5, P6, P2, P5, P6, P2, P5, P4, P1, P3, P2, P1

Now, we know-
 Turn Around time = Exit time – Arrival time
 Waiting time = Turn Around time – Burst time

220031150040 SUYASH SHARMA


P a g e | 28

Now,
 Average Turn Around time = (8 + 17 + 4 + 6 + 17 + 13) / 6
= 65 / 6
= 10.84 unit
 Average waiting time = (4 + 12 + 2 + 5 + 11 + 10) / 6
= 44 / 6
= 7.33 unit

220031150040 SUYASH SHARMA

You might also like