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

Operating System

The document provides information about the operating system (OS) practical file for a Bachelor of Technology student in Electronics and Communication Engineering. It contains two assignments - the first defines and describes the basics of an OS, including its functions like storage management, process management, and memory management. It also lists examples of different OS types like batch, distributed, multitasking, network, and mobile OS. The second assignment introduces Linux/UNIX OS and discusses the Linux kernel and kernel modules.

Uploaded by

Anopp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
73 views

Operating System

The document provides information about the operating system (OS) practical file for a Bachelor of Technology student in Electronics and Communication Engineering. It contains two assignments - the first defines and describes the basics of an OS, including its functions like storage management, process management, and memory management. It also lists examples of different OS types like batch, distributed, multitasking, network, and mobile OS. The second assignment introduces Linux/UNIX OS and discusses the Linux kernel and kernel modules.

Uploaded by

Anopp
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 60

DR B R AMBEDKAR NATIONAL INSTITUTE OF TECHNOLOGY,

Jalandhar (PUNJAB) -144027

PRACTILE FILE

OF

OPERATING SYSTEM (CSPC-232)

SESSION: JAN-MAY(2023)

BACHELOR OF TECHNOLOGY
IN
DEPARTMENT OF ELECTRONICS & COMMUNICATION ENGINEERING

Submitted By- Submitted To:-


Name:- Harjot Singh Dr. Prashant Kumar(Assistant Professor)
Roll no:-21104039 Department of Computer Science & Engineering
ECE,2nd Year
(4th Semester)
OS PRACTICAL 1:-
AIM:- To understand the basics of OS.
DESCRIPTION:-
OPERATING SYSTEM :-
An Operating System (OS) is an interface between a computer user and computer hardware. An operating
system is a software which performs all the basic tasks like file management, memory management, process
management, handling input and output, and controlling peripheral devices such as disk drives and printers.

An operating system is software that enables applications to interact with a computer's hardware. The software
that contains the core components of the operating system is called the kernel.

The primary purposes of an Operating System are to enable applications (softwares) to interact with a
computer's hardware and to manage a system's hardware and software resources.

1|Page
The operating system performs the following functions:
1. Storage Management: Operating system also controls all the storage operations. This means how the data or
files will be stored into the computers and how the file will be accessed by the users etc. Creation of files,
Directories. The operating system performs the following:
 It allows the creation of files and directories.
 It allows the reading of data from and writing of data to files and directories.
 It copies the contents of the files and directories from one place to another.

2. Process Management. The operating system also treats the process management. That is, an operating system
has to handle processes given it by the users; the system own process as well.

3. Memory Management: It manages the sharing of internal memory among multiple applications. E.g., Primary
Memory: RAM, ROM; Secondary Memory: Hard disc, CD, DVD

4. Resources Management: Operating system manages all the resources of the computer system. Both the
hardware (Input, Output and Peripheral) and the software resources.

5. Security Management: these include: Virus management, Alert messages, passwords, Access protection etc

6. Load and run application software: the operating system determines which application should run in what
order and how much time should be allowed for each application before giving another application a turn.

Moreover, Operating System also provides certain services to the computer system in one form or the other.
The Operating System provides certain services to the users which can be listed in the following manner.

1.Program Execution: The Operating System is responsible for the execution of all types of programs
whether it be user programs or system programs. The Operating System utilizes various resources
available for the efficient running of all types of functionalities.

2. Handling Input/output Operations: The Operating System is responsible for handling all sort of inputs,
ie. from the keyboard, mouse, desktop, etc. The Operating System does all interfacing most
appropriately regarding all kind of Inputs and Outputs. For example, there is a difference in nature of all
types of peripheral devices such as mouse or keyboard, then Operating System is responsible for
handling data between them.

3. Manipulation of File System: The Operating System is responsible for making decisions regarding the
storage of all types of data or files, i.e., floppy disk/hard disk/pen drive, etc. The Operating System
decides as to how should the data be manipulated and stored.

2|Page
4. Error Detection and Handling: The Operating System is responsible for the detection of any types 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 to the Computer System from any external source and
probably handling them.

5. Resource Allocation: The Operating System ensures the proper use of all the resources available by
deciding which resource to be used by whom for how much time. All the decisions are taken by the
Operating System.

6. Accounting: The Operating System tracks an account of all the functionalities taking place in the
computer system at a time. All the details such as the types of errors occurred are recorded by the
Operating System.

7. Information and Resource Protection: The Operating System is responsible for using all the
information and resources available on the machine in the most protected way. The Operating System
must foil an attempt from any external resource to hamper any sort of data or information.

3|Page
DIFFERENT TYPES OF OPERATING SYSYTEMS
There are several different types of operating systems present. In this section, we will discuss the advantages
and disadvantages of these types of OS.
Batch OS
Distributed OS
Multitasking OS
Network OS
Mobile OS

Batch OS is the first operating system for second-generation computers. This OS does not directly interact with
the computer. Instead, an operator takes up similar jobs and groups them together into a batch, and then these
batches are executed one by one based on the first-come, first, serve principle.

A distributed OS is a recent advancement in the field of computer technology and is utilized all over the world
that too with great pace. In a distributed OS, various computers are connected through a single communication
channel. These independent computers have their memory unit and CPU and are known as loosely coupled
systems. The system processes can be of different sizes and can perform different functions. The major benefit
of such a type of operating system is that a user can access files that are not present on his system but in another
connected system. In addition, remote access is available to the systems connected to this network.

The multitasking OS is also known as the time-sharing operating system as each task is given some time so that
all the tasks work efficiently. This system provides access to a large number of users, and each user gets the
time of CPU as they get in a single system. The tasks performed are given by a single user or by different users.
The time allotted to execute one task is called a quantum, and as soon as the time to execute one task is
completed, the system switches over to another task.
Network operating systems are the systems that run on a server and manage all the networking functions. They
allow sharing of various files, applications, printers, security, and other networking functions over a small
network of computers like LAN or any other private network. In the network OS, all the users are aware of the
configurations of every other user within the network, which is why network operating systems are also known
as tightly coupled systems.

A mobile OS is an operating system for smartphones, tablets, and PDA’s. It is a platform on which other
applications can run on mobile devices.

4|Page
Examples of Operating System
Following are some examples of Operating Systems:
Microsoft Windows
It is a series of graphical operating systems developed, marketed, and sold by Microsoft. The first version of
Windows was released in 1985 as a GUI add-on to MS-DOS. The first version of Windows sold as a standalone
operating system was Windows 95.
macOS
It is a series of graphical operating systems developed by Apple Inc. It is the successor to Mac OS X, and it is
the operating system that powers Apple’s Mac family of computers.
Linux
Linux is built around the Linux kernel and is a free and open-source software OS. It is one of the most popular
operating systems for servers and embedded devices. It is also used by millions of desktop users around the
world.
Android
It is a mobile OS developed by Google. It is based on the Linux kernel and designed primarily for touchscreen
mobile devices such as smartphones and tablets.
iOS
Another example of a mobile OS developed by Apple Inc. iOs is the successor to iPhone OS. It is an operating
system that powers the iPhone, iPad, and iPod Touch products.

5|Page
OS PRACTICAL 2
AIM:- To understand the UNIX/LINUX OS environment
DESCRIPTION:-

1) INTRODUCTION TO LINUX
LINUX is an operating system or a kernel distributed under an open-source license. Its functionality list is quite
like UNIX. The kernel is a program at the heart of the Linux operating system that takes care of fundamental
stuff, like letting hardware communicate with software.
Linux is one of the most outstanding examples of open-source and free software collaboration. The source code
may be distributed, modified, and used non-commercially or commercially by everyone under the conditions of
its respective licenses.

Kernel modules: It is software that can be unloaded and loaded into the kernel develop functionality without
restarting. Often, kernel modules are used for supporting:
 Device drivers, which utilize code that manages how linked devices work.
 File system drivers, which utilize code that manages how the kernel operates with distinct file systems.

6|Page
 System calls, which utilize code that manages how programs claim services through the kernel.

2) ARCHITECTURE OF LINUX

The Linux operating system's architecture mainly contains some of the components: the Kernel, System
Library, Hardware layer, System, and Shell utility.

1. Kernel:- The kernel is one of the core section of an operating system. It is responsible for each of the
major actions of the Linux OS. This operating system contains distinct types of modules and cooperates
with underlying hardware directly. The kernel facilitates required abstraction for hiding details of low-
level hardware or application programs to the system. There are some of the important kernel types
which are mentioned below:

 Monolithic Kernel
 Micro kernels
 Exo kernels
 Hybrid kernels

2. System Libraries:- These libraries can be specified as some special functions. These are applied for
implementing the operating system's functionality and don't need code access rights of the modules of
kernel.

3. System Utility Programs:- It is responsible for doing specialized level and individual activities.

4. Hardware layer:- Linux operating system contains a hardware layer that consists of several peripheral
devices like CPU, HDD, and RAM.

5. Shell:- It is an interface among the kernel and user. It can afford the services of kernel. It can take
commands through the user and runs the functions of the kernel.

7|Page
3)SYSTEM CALL EXECUTION IN LINUX
A system call is a procedure that provides the interface between a process and the operating system. It is
the way by which a computer program requests a service from the kernel of the operating system.
Different operating systems execute different system calls.
In Linux, making a system call involves transferring control from unprivileged user mode to privileged
kernel mode; the details of this transfer vary from architecture to architecture. The libraries take care of
collecting the system-call arguments and, if necessary, arranging those arguments in the special form
necessary to make the system call.

System calls are divided into 5 categories mainly :


 Process Control
 File Management
 Device Management
 Information Maintenance
 Communication

Process Control :
This system calls perform the task of process creation, process termination, etc.

File Management :
File management system calls handle file manipulation jobs like creating a file, reading, and writing, etc.

Device Management :
Device management does the job of device manipulation like reading from device buffers, writing into
device buffers, etc.

Information Maintenance:
It handles information and its transfer between the OS and the user program. In addition, OS keeps the
information about all its processes and system calls are used to access this information.

8|Page
Communication :
These types of system calls are specially used for inter-process communications.

4)COMMAND STRUCTURE IN LINUX


This terminal is just like the command prompt of Windows OS. Linux/Unix commands are case-
sensitive. The terminal can be used to accomplish all Administrative tasks. This includes package
installation, file manipulation, and user management. Linux terminal is user-interactive. The terminal
outputs the results of commands which are specified by the user itself. Execution of typed command is
done only after you press the Enter key.

To make Linux commands easy to use, they share a simple, common structure. This section describes
their common structure and explains how you can obtain helpful information on the commands available
to you.

The general structure of a Linux/UNIX command line looks like:


command [-flag(s)] [-option(s) [value]] [argument(s)]
The most important thing to note is that the command line usually starts with a “command”, which is an
executable file or program (any file with the executable bit set).

9|Page
OS PRACTICAL 3:-
AIM:- To understand the concept of shell and related commands
DESCRIPTION:-

1)CONCEPT OF SHELL:-

Linux Shell
 The shell can be defined as a command interpreter within an operating system like Linux/GNU
or Unix. It is a program that runs other programs. The shell facilitates every user of the computer
as an interface to the Unix/GNU Linux system. Hence, the user can execute different
tools/utilities or commands with a few input data.
 The shell sends the result to the user over the screen when it has completed running a program
which is the common output device. That's why it is known as "command interpreter".
 The shell is not just a command interpreter. Also, the shell is a programming language with
complete constructs of a programming language such as functions, variables, loops,
conditional execution, and many others.
 For this reason, GNU/Unix Linux Shell is stronger than the Windows shell.

2)Types of Shell:-

Graphical Shells
These shells specifies the manipulation of programs that are based on the graphical user interface (GUI)
by permitting for operations like moving, closing, resizing, and opening windows and switching focus
among windows as well. Ubuntu OS or Windows OS could be examined as a good example that offers a
graphical user interface to the user to interact with the program. Various users don't need for typing in
any command for all the actions.

Command-line Shell
Various shells could be accessed with the help of a command-line interface by users. A unique program
known as Command prompt in Windows or Terminal in macOS/Linux is offered for typing in the

10 | P a g e
human-understandable commands like "ls", "cat", etc and after that, it is being run. The result is further
shown to the user on the terminal.

Bash Shell
In the bash shell, bash means Bourne Again Shell. It is a default shell over several distributions of Linux
today. It is a sh-compatible shell. It could be installed over Windows OS. It facilitates practical
improvements on sh for interactive and programming use which contains:
 Job Control
 Command-line editing
 Shell Aliases and Functions
 Unlimited size command history
 Integer arithmetic in a base from 2-64

Csh (Command Shell)/Tcsh Shell


Tcsh is an upgraded C shell. This shell can be used as a shell script command processor and interactive
login shell.
Tcsh shell includes the following characteristics:

 C like syntax
 Filename completion and programmable word
 Command-line editor
 Job control
 Spelling correction

Ksh (Korn SHell) Shell


Ksh means for Korn shell. It was developed and designed by David G. Korn. Ksh shell is a high-level,
powerful, and complete programming language and it is a reciprocal command language as well just like
various other GNU/Unix Linux shells. The usage and syntax of the C shell are very same as the C
programming language.

11 | P a g e
Zsh Shell
Zsh shell is developed to be reciprocal and it combines various aspects of other GNU/Unix Linux shells
like ksh, tcsh, and bash. Also, the POSIX shell standard specifications were based on the Korn shell.
Also, it is a strong scripting language like other available shells. Some of its unique features are listed as
follows:

 Startup files
 Filename generation
 Login/Logout watching
 Concept index
 Closing comments
 Variable index
 Key index
Function index and various others that we could find out within the man pages.
All these shells do a similar job but take different commands and facilitate distinct built-in functions.

Fish
Fish stands for "friendly interactive shell". It was produced in 2005. Fish shell was developed to be fully
user-friendly and interactive just like other shells. It contains some good features which are mentioned
below:

 Web-based configuration
 Man page completions
 Auto-suggestions
 Support for term256 terminal automation
 Completely scripted with clean scripts

3)ls command and its options.


Linux ls command
The ls is the list command in Linux. It will show the full list or content of your directory. Just
type ls and press the enter key. The whole content will be shown.

12 | P a g e
Linux ls -a command
It will give you the whole list of a directory including the hidden files also. In Linux, hidden files
start with a dot (.) and can't be seen in the regular directory.

Linux ls -l command
The ls command will only display the files. But if you want your files to be displayed in a long
list format, then you can use ls -l command.

Example:

Linux ls -l --block-size=[SIZE]
If you want to display the file size of your list in a particular format or size, then you can use
this command.
Just put the size in place of [SIZE] as per your requirement.

13 | P a g e
Linux ls -d */
If you only want to display the sub-directories excluding all other files, you can use this command.
Example:

4)> option for directing the output of a command.


1. Overwrite
“>” standard output
“<” standard input
So whatever you will write after running this command, all will be redirected and copied to the “file.txt”. This is
standard output redirection.
cat > file.txt
Now, this is standard input redirection, cat command will take the input from “file.txt” and print it to the
terminal screen.
cat < file.txt

14 | P a g e
Commands - pwd, cd, mkdir, rmdir

The pwd(print working directory) command is used to print out the current directory we are in. The syntax is
as follows,

The cd(change directory) command is used to change the current working directory. This command enables
users to navigate through the system's directories.

The mkdir(make directory) command is used to create a new directory.

The rmdir(remove directory) command is used to delete an empty directory.

15 | P a g e
OS PRACTICAL 4:-
AIM:- To understand internal and external commands in linux os
DESCRIPTION:-

1)Internal and external commands :-

Internal Commands : Commands which are built into the shell. For all the shell built-in commands, execution
of the same is fast in the sense that the shell doesn’t have to search the given path for them in the PATH
variable, and also no process needs to be spawned for executing it.

Examples: source, cd, fg, etc.

External Commands : Commands which aren’t built into the shell. When an external command has to be
executed, the shell looks for its path given in the PATH variable, and also a new process has to be spawned
and the command gets executed. They are usually located in /bin or /usr/bin. For example, when you execute
the “cat” command, which usually is at /usr/bin, the executable /usr/bin/cat gets executed.

Examples: ls, cat etc .

Since ls is a program or file having an independent existence in the /bin directory(or /usr/bin), it is branded as
an external command that actually means that the ls command is not built into the shell and these are
executables present in a separate file. In simple words, when you will key in the ls command, to be executed
it will be found in /bin. Most commands are external in nature, but there are some which are not really found
anywhere, and some which are normally not executed even if they are in one of the directories specified by
PATH. For instance, take echo command:

$type echo

echo is a shell builtin

echo isn’t an external command in the sense that, when we type echo, the shell won’t look in its PATH to
locate it(even if it is there in /bin). Rather, it will execute it from its own set of built-in commands that are not
stored as separate files. These built-in commands, of which echo is a member, are known as internal
commands.

It’s the shell that actually does all these works. This program starts running as soon as the user log in and
dies when the user logs out. The shell is an external command with a difference, it possesses its own set of
internal commands. So, if a command exists both as an internal command of the shell as well as external
one(in /bin or /usr/bib), the shell will accord top priority to its own internal command of the same name.

16 | P a g e
This is exactly the case with echo which is also found in /bin, but rarely ever executed because the shell
makes sure that the internal echo command takes precedence over the external. Now, talk more about the
internal and external commands.

Getting the list of Internal Commands

If you are using bash shell you can get the list of shell built-in commands with help command :

$help

this will list all the shell built-in commands

In addition to this you can also find out about a particular command i.e whether it is internal or external with
the help of type command :

17 | P a g e
$type cat

specifying that cat is

external type

$type cd

specifying that cd is

internal type

18 | P a g e
OS PRACTICAL 5:-

AIM:- To understand the basics file attributes

Description:-

Types of files and file system in Linux.

Linux Files:- In Linux system, everything is a file and if it is not a file, it is a process. A file doesn't include
only text files, images and compiled programs but also include partitions, hardware device drivers and
directories. Linux consider everything as a file.

Files are always case sensitive. Let's understand it through an example.

Linux Files

In above example, we have two files named as 'File.txt' and 'file.txt'. Although, they both share the same
name but still they are two different files.

Types of Files:

 Regular files (-): It contain programs, executable files and text files.

 Directory files (d): It is shown in blue color. It contain list of files.

 Special files

 Block file (b)

 Character device file (c)

 Named pipe file (p)

 Symbolic link file (l)

 Socket file (s)

19 | P a g e
1. Basic file attributes: ls –l, -d option.
Linux ls -l command
The ls command will only display the files. But if you want your files to be displayed in a long list
format, then you can use ls -l command.

Column 1 indicates information regarding file permission.


Column 2 indicates the number of links to the file.
Column 3 & 4 indicates the owner and group information.
Column 5 indicayes size of the file in bytes.
Column 6 shows th date and time on which the file was recently modified.
Column 7 shows the file or directory name.

Linux ls -d */
If you only want to display the sub-directories excluding all other files, you can use this command.

Example: ls -d */

20 | P a g e
2) File permissions and changing the access rights.

 The first character will almost always be either a ‘-‘, which means it’s a file, or a ‘d’, which means it’s
a directory.
 The next nine characters (rw-r–r–) show the security.
 The next column shows the owner of the file. In this case, “harjotsingh39”.
 The next column shows the group owner of the file. “harjotsingh39” group of people special access to
these files.
 The next column shows the size of the file in bytes.
 The next column shows the date and time the file was last modified.
 And, of course, the final column gives the filename.

Understanding the security permissions:-


Each of the three “rwx” characters refers to a different operation you can perform on the file.
--- --- ---
rwx rwx rwx
user group other

Read, write, execute and –


The ‘r’ means you can “read” the file’s contents.
The ‘w’ means you can “write”, or modify, the file’s contents.
The ‘x’ means you can “execute” the file. This permission is given only if the file is a program.

21 | P a g e
If any of the “rwx” characters is replaced by a ‘-‘, then that permission has been revoked.

User, group and others


user – The user permissions apply only the owner of the file or directory, they will not impact the
actions of other users.
group – The group permissions apply only to the group that has been assigned to the file or directory,
they will not effect the actions of other users.
others – The others permissions apply to all other users on the system, this is the permission group that
you want to watch the most.

Changing security permissions


The command you use to change the security permissions on files is called “chmod”, which stands for
“change mode”, because the nine security characters are collectively called the security “mode” of the
file.
The first argument you give to the “chmod” command is ‘u’, ‘g’, ‘o’. We use:
u for user
g for group
o for others,
you can also use a combination of them (u,g,o).
This specifies which of the three groups you want to modify.

After this use


a ‘+’ for adding
a ‘-‘ for removing
and a “=” for assigning a permission.
Then specify the permission r,w or x you want to change.
Here also you can use a combination of r,w,x.
This specifies which of the three permissions “rwx” you want to modify
use can use commas to modify more permissions
Finally, the name of the file whose permission you are changing

22 | P a g e
OS PRACTICAL 6:-
AIM:- To understand the concept of the Vim editor and related commands.
DESCRIPTION:- Vim is a powerful and popular text editor that is commonly used in the Unix/Linux
environment. It offers a range of features and commands that can help you edit and manipulate text more
efficiently. In this practical, you will learn some of the basic commands and features of Vim that can help you
get started with using this powerful text editor.
SOURCE CODE:-

1.Launch the Vim Editor by typing "vim" in the terminal:

2.Create a new file or open an existing file by typing the file name after "vim":

3.Once you are in the editor, use the arrow keys or "h", "j", "k", and "l" keys to move the cursor around the
file. Press the "i" key to enter insert mode and start typing.

4.While in insert mode, you can type text as you would in any other text editor. To exit insert mode, press the
"Esc" key. Once you have exited insert mode, you can use various commands to manipulate the text.

5.To save the changes made to the file, press the ":" key to enter command mode. Then type "w" followed by
the file name and press "Enter". This will save the changes to the file.

6.To quit the Vim Editor, press the ":" key to enter command mode. Then type "q" and press "Enter". If you
have unsaved changes, Vim Editor will prompt you to save them before quitting.

7.Advanced commands include:

 "dd" to delete a line

 "yy" to copy a line

 "p" to paste a copied or deleted line

 "u" to undo the last action

23 | P a g e
 "Ctrl + r" to redo the last action

OUTPUT:-

OS PRACTICAL 7:-

AIM:- To understand shell scripting using variable passing arguments.

DESCRIPTION:- Shell scripting is a powerful tool for automating tasks and processes in a Unix/Linux
environment. One of the most important concepts in shell scripting is the use of variables and passing
arguments. Variables allow us to store and manipulate data, while passing arguments allows us to provide input
to our shell scripts. In this practical, we will create a simple script that demonstrates the use of variables and
passing arguments.

CODE:-

24 | P a g e
OUTPUT:-

25 | P a g e
OS PRACTICAL 8:-
AIM:- To understand shell scripting using while loops, arithmetic and logical operators, and the append
command.
DESCRIPTION:- In this practical, we will create a shell script that will perform arithmetic and logical
operations using while loops. We will also use the append command to store the output of each iteration into a
file.
SOURCE CODE:-

26 | P a g e
Output Section:
When you run the script, it will create a file called output.txt in the same directory as the script. The contents of
the file will be as follows:

The script will perform the following operations:

1. Define two variables i and sum and set their initial values to 1 and 0 respectively.
2. Create a file called output.txt to store the output of each iteration.
3. Use a while loop to iterate from 1 to 10.
4. Use an if statement to skip iteration 5.
5. Use another if statement to add even numbers to the sum.
6. Use the append command (>>) to add the output of each iteration to the output.txt file.
7. Increment the value of i by 1.
8. Repeat steps 4 to 7 until the loop completes.

27 | P a g e
OS PRACTICAL 9:-
AIM:- To understand shell scripting using file test operators and other base operators.
DESCRIPTION:- In this practical, we will create a shell script that checks whether a file exists, is readable,
writable, or executable. We will also use other base operators like the arithmetic operator to perform basic
arithmetic operations.
SOURCE CODE:-

28 | P a g e
Output:-

29 | P a g e
In the above script, we first prompt the user to enter the file name and then check if the file exists, is readable,
writable, or executable using the file test operators. We then perform arithmetic operations on the two numbers
entered by the user using the arithmetic operator.

OS PRACTICAL 10:-

30 | P a g e
10A)AIM:- To understand the First Come First Serve (FCFS) process scheduling algorithm with an
algorithm and C++ code.
DESCRIPTION:- The First Come First Serve (FCFS) scheduling algorithm is a simple scheduling
algorithm that schedules processes based on their arrival time. In this algorithm, the process that arrives
first gets executed first, and so on. The process with the earliest arrival time is given the highest priority,
and the process with the latest arrival time is given the lowest priority. In this practical, we will
implement the FCFS scheduling algorithm using C++ and understand its working.

SOURCE CODE:-

OUTPUT SECTION:

31 | P a g e
32 | P a g e
10B)AIM:- To understand the Shortest Job First process scheduling algorithm with the help of an
algorithm and C++ code.

DESCRIPTION:- The Shortest Job First (SJF) process scheduling algorithm is a non-preemptive
scheduling algorithm that selects the process with the shortest burst time (execution time) from the ready
queue to execute next. The SJF algorithm can minimize the average waiting time for processes, as
shorter processes are executed first, which means they spend less time waiting in the ready queue. In this
practical, we will implement the SJF algorithm using C++ code.

SOURCE CODE:-

OUTPUT SECTION:-

33 | P a g e
10C) AIM:- The aim of this practical is to understand the shortest job remaining first (SJRF) process
scheduling algorithm and implement it using C++ programming language.

DESCRIPTION:- Process scheduling is an important concept in operating systems. It determines which


process should be executed first and for how long. SJRF is a scheduling algorithm that selects the
process with the shortest remaining burst time to be executed next. In this practical, we will implement
SJRF using C++ programming language.

SOURCE CODE:-

34 | P a g e
OUTPUT:-

35 | P a g e
OS PRACTICAL 11:-

11A)AIM:- To understand Round Robin Process Scheduling with C++ code.


DESCRIPTION:-In computer science, process scheduling is an essential task performed by the operating
system to allocate system resources to various processes. Round Robin scheduling is one of the most widely
used scheduling algorithms. It is a preemptive algorithm in which each process is given a time quantum to
execute, after which it is preempted and the next process is scheduled for execution. The process that has been
preempted is placed at the end of the queue, and the scheduling continues in a circular manner. The time
quantum is usually a small fraction of the total execution time of the process.

SOURCE CODE:-

36 | P a g e
OUTPUT SECTION:-

37 | P a g e
11B) AIM:- To understand priority non-preemptive process scheduling with C++ code.
DESCRIPTION :- In priority non-preemptive process scheduling, the process with the highest priority is
selected to run first, and once a process starts running, it will continue to run until it finishes or another process
with higher priority arrives. In this practical, we will implement a priority non-preemptive process scheduling
algorithm in C++ and simulate it with some sample processes.
SOURCE CODE:-

OUTPUT SECTION:-

38 | P a g e
11C) AIM:- To understand priority preemptive process scheduling with C++ code.
DESCRIPTION:-In a priority preemptive scheduling algorithm, the process with the highest priority gets
executed first, and if a process with a higher priority enters the system, it preempts the currently running
process.
SOURCE CODE:-

39 | P a g e
OUTPUT SECTION:-

40 | P a g e
OS PRACTICAL 12
12A) AIM:- To understand producer-consumer process synchronization with C code.
DESCRIPTION:- In a producer-consumer problem, we have two types of threads, producers and consumers.
Producers produce data and add it to a shared buffer, while consumers consume data from the same buffer. The
problem is to ensure that producers do not produce data when the buffer is full, and consumers do not consume
data when the buffer is empty. To solve this problem, we can use semaphores or mutexes to control access to
the shared buffer. Semaphores are variables that are used to signal between threads, while mutexes are used to
protect critical sections of code.
SOURCE CODE:-

41 | P a g e
OUTPUT SECTION:-

42 | P a g e
12 B) AIM:- To understand reader-writer process synchronization using C++ code.
DESCRIPTION:- Reader-writer process synchronization is an essential concept in concurrent programming,
where multiple processes compete for shared resources. In this practical, we will simulate a scenario where
multiple readers and writers access a shared data structure simultaneously. We will use an algorithm called the
"reader-writer lock" to synchronize access to the shared data structure and prevent race conditions.

SOURCE CODE:-

43 | P a g e
OUTPUT SECTION:-

44 | P a g e
OS PRACTICAL 13:-
AIM:- To understand the Banker's Algorithm with C++ code.
DESCRIPTION:- The Banker's Algorithm is a resource allocation and deadlock avoidance algorithm that is
used in operating systems. It is used to avoid deadlocks by checking the safety of a system's state and
determining whether a request for resources will leave the system in a safe state or not
SOURCE CODE:-

45 | P a g e
46 | P a g e
OUTPUT SECTION:-

47 | P a g e
OS PRACTICAL 14
14A) i) AIM:- To understand the contiguous first fit memory allocation strategy.
DESCRIPTION:- In the contiguous first fit memory allocation strategy, the operating system
allocates memory to a process by searching for the first available block of memory that is large enough to
accommodate the process's memory requirements. The search starts from the beginning of the memory space
and continues until a suitable block of memory is found.
SOURCE CODE:-

48 | P a g e
OUPUT SECTION:-

49 | P a g e
14A) ii) AIM:- To understand non contiguous first fit memory allocation strategy.
DESCRIPTION :- Non-contiguous memory allocation refers to the allocation of memory segments
that are not physically adjacent to each other. In the first fit strategy, the operating system starts
searching for available memory blocks from the beginning of the memory pool and assigns the first
block that is large enough to meet the process's memory requirements. This strategy is simple and
easy to implement, but it can lead to memory fragmentation, which can affect system performance.

SOURCE CODE:-

50 | P a g e
OUTPUT SECTION : -

51 | P a g e
14 B)i) AIM :- The aim of this practical is to understand the contiguous best fit memory allocation strategy.
DESCRIPTION: - In the contiguous best fit memory allocation strategy, the operating system searches
the memory space for the smallest available block of memory that is large enough to hold the process.
This ensures that the memory is used efficiently, as it minimizes the amount of fragmentation that
occurs in the memory space.
SOURCE CODE: -

52 | P a g e
OUTPUT SECTION:-

53 | P a g e
14B) ii) AIM:- To understand non-contiguous best-fit memory allocation strategy.
DESCRIPTION:-The non-contiguous best-fit memory allocation strategy is a dynamic memory allocation
technique used by operating systems. In this strategy, the available memory is divided into different non-
contiguous blocks of various sizes. When a request for memory allocation is made, the system searches for the
smallest block of memory that can accommodate the request. This approach results in minimal wastage of
memory.

SOURCE CODE:-

54 | P a g e
OUTPUT SECTION:-

55 | P a g e
14C) i) AIM:- To understand contiguous worst fit memory allocation strategy.
DESCRIPTION:- In computer science, memory allocation is a process of allocating a portion of memory to a
program or a process. Contiguous memory allocation is a method of allocating contiguous blocks of memory to
processes. The worst fit memory allocation strategy allocates the largest available block of memory to a
process.
SOURCE CODE:-

56 | P a g e
OUTPUT SECTION:-

57 | P a g e
14C) ii) AIM:- To understand the non-contiguous worst-fit memory allocation strategy.
DESCRIPTION:- In this practical, we will explore the non-contiguous worst-fit memory allocation strategy,
which is a memory allocation technique used in computer operating systems. This strategy aims to allocate the
largest available block of memory to a process, even if it is not contiguous with the previously allocated
memory.
SOURCE CODE:-

58 | P a g e
OUPUT SECTION:-

59 | P a g e

You might also like