Operating System
Operating System
Operating System
Practical File
Of
Operating System
(22CS005)
Submitted
BACHELOR OF ENGINEERING
in
CHITKARA UNIVERSITY
JUNE 2024
S. No Practical Remarks
1. Installation and configuration of Linux
Operating system.
To illustrate basic of GCC compiler i.e.,
compilation and execution of a program
Time stamping in linux
Automating the execution using make file
2. Implement the basic and user status commands like:
su, sudo, man, help, history, who, who am i, id,
uname, uptime, free, tty, cal, date, hostname, reboot,
clear
3. Implement the commands that is used for Creating
and Manipulating files: cat, cp, mv, rm, ls and its
options, touch and their options, which is, where is,
what is
4. Implement Directory oriented commands: cd, pwd,
mkdir, rmdir, Comparing Files using diff, cmp,
commands
5. Write a program and execute the same to
demonstrate how to use terminal commands in C
program (using system() function)
6. Write a program to implement process concepts
using C language by printing process Id.
7. Write a program to create and execute process using
fork() and exec() system calls.
8. Implement FCFS , SIF , priority scheduling and
round robin scheduling in C Language.
9. Implement DeadLock In C-Language.
Experiment – 1
Aim:-
Installation and configuration of Linux Operating system.
Theory:-
Linux is an open source , Unix-like operating system kernel .It is like
the heart of a computer, managing everything that goes on inside. It's
free to use and built by a community of developers worldwide. With
Linux, we can customize our computer just the way we like it, from
how it looks to what it does. It's super reliable, meaning it doesn't crash
often, and it's great for running all kinds of programs, from browsing the
internet to creating documents and even powering big servers for
websites. . Popular Linux distributions include Ubuntu, Fedora, CentOS
, Debian, and Arch Linux, each with its own characteristics and package
management systems.
Operating System (22CS005)
Linux Distributions:-
Linux distributions, or "distros," are customized versions of the Linux
operating system. They vary in pre-installed software, desktop
environments, and intended use. Popular distros include Ubuntu for
user-friendliness, Debian for stability, Fedora for cutting-edge features,
CentOS for servers, and Arch Linux for minimalism. Each distro offers
unique features and community support.
1. Ubuntu:
Description: Ubuntu is User-friendly Linux distro based on Debian,
offering stability with up-to-date features. Supports various desktop
environments, widely used for desktops, servers, and cloud
deployments.
Package Management: APT (Advanced Package Tool)
Desktop Environment: Ubuntu offers desktop environments like
GNOME (default), KDE Plasma, Xfce, LXQt, and MATE for users to
customize their experience.
Operating System (22CS005)
2. Fedora:
Description: Sponsored by Red Hat, Fedora is a cutting-edge
distribution that emphasizes the use of the latest software and
technologies.
Package Management: DNF (Dandified YUM)
Desktop Environment: Default is GNOME, but it supports various
desktop environments.
3. Debian:
Description: Debian is known for its stability and commitment to
free and open-source software principles. It serves as the foundation
for several other distributions.
Package Management: APT (Advanced Package Tool)
Desktop Environment: Varies, can be customized during
installation.
4. CentOS:
Description: Derived from the sources of Red Hat Enterprise Linux
(RHEL), CentOS is a free, community-supported distribution known
for its stability and reliability.
Package Management: YUM (Yellowdog Updater, Modified)
Desktop Environment: Primarily used for servers; desktop
environments can be added as needed.
5. Arch Linux:
Description: Arch Linux is a rolling release distribution known for its
simplicity and customization. It follows a "do-it-yourself" philosophy.
Package Management: Pacman
Desktop Environment: None by default; users can choose and install
their preferred desktop environment.
6. openSUSE:
Operating System (22CS005)
Description: openSUSE is a distribution sponsored by SUSE Linux
GmbH and is known for its robustness and user-friendly
administration tools.
Package Management: Zypper
Desktop Environment: Default is KDE Plasma, but it supports various
desktop environments.
7. Mint:
Description: Linux Mint is based on Ubuntu and Debian and is
designed to be user-friendly, with a focus on providing a familiar
desktop experience for users switching from other operating systems.
Package Management: APT (Advanced Package Tool)
Desktop Environment: Cinnamon (default), MATE, Xfce.
To download ubuntu :-
Prepare Disk Space: Make sure we have enough free space on your
laptop's hard drive to install Ubuntu. we may need to resize our existing
partitions to create space for Ubuntu.
Operating System (22CS005)
Download Ubuntu:- After downloading the Virtual-Box , download an
Ubuntu software file in the device by following simple steps
1. Mount the ISO File: Once the ISO file is downloaded, we can
mount it by simply double clicking on it in our file manager.
2. Start the Installation: Within the mounted ISO file, we will find
the installer program. Run the installer program to start the Ubuntu
installation process.
4. Configure Ubuntu: Create a user account, set your time zone, and
choose your preferences for updates and additional software during
the installation process.
GCC COMPILER
Timestamp from File: To get the timestamp of a file, you can use
the stat command followed by the file name.
Modification Time: If you're interested in the last modification
time of a file, you can use the -c %y option with the ls command.
Operating System (22CS005)
EXPERIMENT-2
Implement the basic and user status commands
Sudo :- It allows authorized users to perform administrative tasks
that require elevated permissions, such as installing or removing
software, modifying system configurations, or managing system
services.
Man :- man stands for "manual" it includes commands like system
calls, library functions, configuration files, and more.
Uname:- it used to display the name of the person using it.
Help:- help is a built-in command that provides information and
usage instructions for built-in shell commands.
Who:- it displays information about users currently logged in,
including usernames and login times.
Whoami :- it displays the username associated with the currently
active user session.
Cal:- it displays a calendar for a specified month or the current
month by default.
History:- it gives all the commands which we can use.
Date:- it displays the current date and time information according
to the system's settings.
Clear:-this command is used to clear the terminal.
Hostname:- it gives the name of the software we were using
In this case (ubuntu) is our hostname
Operating System (22CS005)
Operating System (22CS005)
Operating System (22CS005)
Operating System (22CS005)
EXPERIMENT – 3
COMMANDS FOR CREATING AND MANIPULATING FILES:-
Cat:- cat command displays the content of one or more files in the
terminal.
Cp:-cp command is used to copy the content of any file to another
new one.
Mv:- The mv command is used to move or rename files and
directories within the file system.
Rm:- The rm command is used to remove or delete files and
directories from the file system.
Ls:- ls command is used to list all the files present in the directory.
Touch:- The touch command is used to create an empty file or
update the access and modification timestamps of an existing file.
Operating System (22CS005)
Operating System (22CS005)
EXPERIMENT -4
IMPLEMENT DIRECTORY ORIENTED COMMANDS:-
EXPERIMENT - 5
Write a program and execute the same to demonstrate how to use
terminal commands in C Program(using system( ) function ):
THEORY:-
Using the system() function in C allows you to execute terminal
commands directly from within a C program. This can be useful for
automating tasks or interacting with the operating system.
EXPERIMENT - 6
Write a program to implement process concepts using C language
by printing process Id.
Process Id :-
A process ID (PID) is a unique identifier assigned to each running
process in an operating system. It is used to identify and manage
processes in a system .
Operating System (22CS005)
EXPERIMENT -7
What is fork? :- It's like making a copy of your program while it's
running.We create a new process that's a copy of the current one.
Why we use it :-We might use it when you want to do two things at
once in your program, like running a server while also handling user
requests.
Write a program to create and execute the process using fork( ) system
call.
Q1}
Operating System (22CS005)
Q2}
20 times “1”
Operating System (22CS005)
Q3}
EXPERIMENT :- 8
AIM: Implement FCFS , SIF , priority scheduling and round robin scheduling in
C Language.
THEORY:
First Come, First Served (FCFS) also known as First In, First Out (FIFO) is the
CPLI scheduling algorithm in which the CPU is allocated to the processes in the
order they are queued in the ready queue FCFS follows non preemptive
scheduling which mean once the CPU is allocated to a process it does not leave
the CPU until the process will not get terminated or may get halted due to some
1/0 interrupt
Shortest Job First (SJF) is an algorithm in which the process having the
smallest execution time is chosen for the next execution. This scheduling method
can be preemptive or non-preemptive. It significantly reduces the average
waiting time for other processes awaiting execution. The fall form of SIF is
Shortest Job First
Priority Scheduling is a method of scheduling processes that is based on
priority. Lt this algorithms, the scheduler selects the tasks to work as per the
priority. The processes with higher priority should be carried out first, whereas
jobs with equal priorities are carried out or a round-robin or ICFS basis. Priority
depends upon memory requirements, time requirements, etc.
Round Robin Scheduling comes from the round-robin principle, where each
person gets an equal share of something in turns. It is the oldest, simplest
scheduling algorithm, which is mostly used for multitasking In Round-robin
scheduling, each ready task runs turn by turn only in a cyclic queue for a limited
time slice. This algorithm also offers starvation free execution of processes
Operating System (22CS005)
PROCEDURES:
(A). FCFS: (First Come First Serve)
Operating System (22CS005)
EXPERIMENT :- 9
AIM:- Implement DeadLock In C-Language.
THEORY:-
Deadlock in C occurs when multiple processes compete for resources
and get stuck waiting for each other to release resources they need. It
happens when each process holds a resource and waits for another
resource held by another process. In C, this can result from improper
synchronization mechanisms like semaphores. Deadlock prevention
strategies include resource ordering, timeout mechanisms, and avoiding
circular wait conditions. Proper resource management and
synchronization techniques are crucial to prevent deadlock situations in
C programs.
Operating System (22CS005)
PROCEDURES:-
Experiment: 10
File system: Introduction of File system, File system architecture and
file types.
A file system is a method an operating system uses to store, organize,
and manage files and directories on a storage device. Some common
types of file systems include:
1. FAT (File Allocation Table): An older file system used by older versions
of Windows and other operating systems.
2. NTFS (New Technology File System): A modern file system used by
Windows. It supports features such as file and folder permissions, compression,
and encryption.
3. ext (Extended File System): A file system commonly used on Linux and
Unix-based operating systems.
4. HFS (Hierarchical File System): A file system used by macOS.
5. APFS (Apple File System): A new file system introduced by Apple for
their Macs and iOS devices.
Along with a file's content data, a file system maintains metadata about the files
along with other information. The metadata might include details such as the file
size, creation date or location in the directory.
Most file systems organize files in a directory hierarchy, with a file's location
described by its path within the directory structure. The directories are organized
into an inverted hierarchical tree structure, with the root directory at the top. Each
file is placed in a directory or subdirectory at the desired location within the tree
structure.
A file system divides a partition into blocks, and their size depends on
the file system. Most of the blocks are used for the files' content data.
The remaining blocks are divided between the files' metadata and the
file system's management data. Figure 2 provides a conceptual overview
how a file system in a Unix-like environment might organize the data
across the individual blocks. In this case, the metadata is stored in index
nodes (inodes). An inode is an indexable data structure that maintains
details about a file or directory.
The management data occupies the first few blocks, followed by the
inode metadata and then the content data blocks, which consume most
of the storage. Here's a breakdown of the different block types:
• Super block. The block contains information about the file system
itself, acting as its own metadata repository. For example, the super
block might include details about the file system type, total number of
blocks, number of inodes or other components.
• Data block bitmap. The block contains a simple bitmap that
indicates which data blocks are used or unused. A value of 1 indicates
the block is used, and a value of 0 indicates it is unused.
Operating System (22CS005)