0% found this document useful (0 votes)
17 views90 pages

Os Lab

The document is a practical file for an Operating Systems lab, detailing various operating systems including Windows, Linux, and macOS, along with their features, functionalities, and differences. It covers process management, scheduling algorithms, and specific characteristics of each OS. The file is submitted by Ishan Watts to Dr. Amita Malik at Deenbandhu Chhotu Ram University of Science and Technology.

Uploaded by

allez6903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views90 pages

Os Lab

The document is a practical file for an Operating Systems lab, detailing various operating systems including Windows, Linux, and macOS, along with their features, functionalities, and differences. It covers process management, scheduling algorithms, and specific characteristics of each OS. The file is submitted by Ishan Watts to Dr. Amita Malik at Deenbandhu Chhotu Ram University of Science and Technology.

Uploaded by

allez6903
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Practical File

Of
OS Lab

Submitted To: Submitted By:

Dr. Amita Malik Ishan Watts

Dept. of CSE B.Tech CSE-II-G3

Roll No: 22001001048

__________________________________________________________________________________________
_
Deenbandhu Chhotu Ram University of Science and Technology
Murthal, Sonipat- INDIA,
A Haryana State Government University
Index

Sr. Aim Date Sign.


No.
Experiment-01

Aim- Study of different Operating Systems (Windows, Linux, Mac


OS).

Operating System
An operating system acts as an interface between the software and different
parts of the computer or the computer hardware. The operating system is
designed in such a way that it can manage the overall resources and
operations of the computer.

Operating System is a fully integrated set of specialized programs that handle


all the operations of the computer. It controls and monitors the execution of
all other programs that reside in the computer, which also includes
application programs and other system software of the computer. Examples of
Operating Systems are Windows, Linux, Mac OS, etc.

Windows Operating system

It is a GUI-based operating system that is developed and marketed by Microsoft


Corporation. The main objective of Microsoft company regarding this operating system is
to make it an all-rounder and easy-to-use OS that has everything so that any normal user
who doesn’t have knowledge about coding can easily use this operating without any issue.

It comes up with a clean desktop environment that looks minimal and easy to use. It also
comes up with a pre-loaded application like Microsoft Excel, PowerPoint, Microsoft Edge
browser, Microsoft store, some basic games, and many other applications come. It allows
the user to do multitask, play games, watch videos, browse the internet, chats with
friends/family, and even you can install any software without any issue.

Features in Windows Operating System


Microsoft Windows includes a lot of features to help users. Some of its excellent features
are as follows:

Desktop: Desktop is a by-default GUI-based Screen provided by the Microsoft in windows


OS. It is a place where all the software applications icons are available on a screen, so the
users can do their work by clicking on these applications.

Control Panel: Windows provides a Control Panel feature that includes many tools to
configure and manage the resources on their computer. For example, users can change
settings for audio, video, printers, mouse, keyboard, network connections, date and time,
power saving options, user accounts, installed applications, etc.

File Explorer: It is also known as Windows Explorer, which displays your files and folders
on the computer. It allows users to browse the data on the hard drive, SSD and other
inserted removable disks like pen drives and CDs, and you can manage the content
according to the requirements such as delete, rename, search, and transfer the data.

Internet browser: As the internet browser is very important to search for anything, view
pages, online shopping, play games, watch videos, etc. Windows come with a pre-installed
internet browser. in Windows 10, the Edge internet browser is the default browser.
Furthermore, Internet Explorer was the default browser in Microsoft Windows from the
Windows edition 95 to 8.1 version.

Microsoft Paint: Since November 1985, Microsoft Windows comes with pre-installed
Microsoft Paint. It is a simple software to create, view, and edit an image. It offers several
tools to draw an image, crop, resize, and save an image with a different file extension.

Taskbar: Windows comes with a taskbar that displays currently opened programs, it also
allows users to access any specific programs. Additionally, it includes the notification area
on the right side that shows date and time, battery, network, volume, and other background
running applications.

Start menu: Microsoft Windows contains a start menu to the left side of the taskbar. It
displays programs and utilities that are installed on the computer. It can be simply opened
by clicking on the Start menu button or pressing the start key on the keyboard.

Task Manager: Windows includes the task manager feature that provides detail of the
running applications or programs on the computer. You can also check how much of the
system resources, such as RAM, CPU, disk I/O, are being used by each of the applications .

Recycle Bin: It is a place where all the deleted files and applications are stored. It provides
a facility of restore point where we can restore any deleted files or applications of our
system. If you delete any files or applications from the recycle bin then you will no longer
restore them, they will be permanently deleted.

Versions of Windows Operating System

a) Windows 1 b) Window 2 c) Window 386 d)Window 286


e) Window 3 f) Window 3.1 g) Windows 95 h) Windows 98
i) Windows 2000 j) Windows XP k) Windows Vista l) Window 7
m) Window 8 n) Window 8.1 o) Window 10 p) Window 11
Linux Operating System

The Linux Operating System is a type of operating system that is similar to Unix, and it is
built upon the Linux Kernel. The Linux Kernel is like the brain of the operating system
because it manages how the computer interacts with its hardware and resources. It makes
sure everything works smoothly and efficiently. But the Linux Kernel alone is not enough to
make a complete operating system. To create a full and functional system, the Linux Kernel
is combined with a collection of software packages and utilities, which are together called
Linux distributions. These distributions make the Linux Operating System ready for users
to run their applications and perform tasks on their computers securely and effectively.
Linux distributions come in different flavors, each tailored to suit the specific needs and
preferences of users.

Linux Distribution

Linux distribution is an operating system that is made up of a collection of software based


on Linux kernel or you can say distribution contains the Linux kernel and supporting
libraries and software. And you can get Linux based operating system by downloading one
of the Linux distributions and these distributions are available for different types of devices
like embedded devices, personal computers, etc. Around 600 + Linux Distributions are
available and some of the popular Linux distributions are:

MX Linux Manjaro Linux Mint elementary Ubuntu


Debian Solus Fedora openSUSE Deepin

The Linux OS system incorporates several different components, including:

Bootloader-A bootloader is responsible for managing the boot process of the computer
and for starting the Linux kernel. It can also be used to manage systems that boot more
than one OS.

Kernel – This is the one piece of the whole that is actually called ‘Linux’. The kernel is the
core of the system and manages the CPU, memory, and peripheral devices. The kernel is the
lowest level of the OS.

Init system.-The first process to run once the kernel is loaded. A process is an instance of a
program running on a computer, and the init system initializes the system to enable it to
run other processes. Init is a daemon program that acts as the parent process to all other
processes running on the system. Init can be configured to start specific processes at
system initialization. For example, when the system will be running a web server the init
system can be configured to load all necessary web server software.
Daemons.-This is a program that runs in the background, handling requests for a service. A
web server running on a Linux server depends on a daemon, usually named httpd, to listen
for web server requests.

Graphical server – This is the sub-system that displays the graphics on your monitor. It is
commonly referred to as the X server or just X.

Desktop environment – This is the piece that the users actually interact with. There are
many desktop environments to choose from (GNOME, Cinnamon, Mate, Pantheon,
Enlightenment, KDE, Xfce, etc.). Each desktop environment includes built-in applications
(such as file managers, configuration tools, web browsers, and games).

Applications – Desktop environments do not offer the full array of apps. Just like Windows
and macOS, Linux offers thousands upon thousands of high-quality software titles that can
be easily found and installed. Most modern Linux distributions (more on this below)
include App Store-like tools that centralize and simplify application installation. For
example, Ubuntu Linux has the Ubuntu Software Center (a rebrand of GNOME Software)
which allows you to quickly search among the thousands of apps and install them from one
centralized location.

Mac Operating System


macOS (previously known as OS X) is the operating system developed by Apple Inc. for its
Mac line of personal computers and workstations. The abbreviation "macOS" stands for
"Macintosh Operating System. It was first introduced in 2001 as the successor to the
classic Mac OS. Since then, it has undergone many updates and improvements to become
the sophisticated and user-friendly operating system it is today.

macOS is built on a Unix-based architecture and provides users with a stable, reliable, and
user-friendly experience. The operating system is designed to be intuitive and easy to use,
focusing on simplicity and elegance. The user interface of macOS is clean, organized, and
aesthetically pleasing, making it a pleasure to use for both casual and professional users
alike.

In addition to its sleek design and user-friendly interface, macOS is also known for its
stability and security. With its robust security features, the operating system helps to
protect users' data and privacy, making it a popular choice for individuals and
organizations.

The Architecture of macOS

The architecture of macOS is built on a Unix-based foundation and is designed to offer


stability, performance, and security.
o The operating system's core comprises a set of open-source components, including
the Mach kernel, the BSD Unix layer, and various other libraries and tools.
o The key feature is the use of protected memory, which isolates each running
application and allocates a specific portion of memory that cannot be accessed or
overwritten by other applications.
o It supports 64-bit computing, allowing the operating system to take advantage of
the full capabilities of modern Mac hardware and provide users with a more
responsive and efficient experience.
o It offers built-in security features, such as sandboxing, which helps to prevent
malware and other malicious software from accessing the system.
o Includes powerful system-level APIs and frameworks that allow developers to
create a wide range of applications, from simple utilities to complex, professional-
level software.

Exploring the Features and Functionality of macOS

macOS is the operating system that powers the Apple Mac computer line. It offers users a
rich set of features and functionality that provides a seamless and intuitive computing
experience.

Desktop Interface

o Clean and uncluttered interface, with a focus on simplicity and ease of use
o The Dock, located at the bottom of the screen, provides quick access to frequently
used applications and documents.
o The Launchpad offers a grid-like interface for easily accessing and organizing all
installed applications.

Productivity and Efficiency

o Built-in apps for tasks such as email, web browsing, and productivity
o Advance1d features like Continuity, which allows users to start a task on one Apple
device and continue on another
o The ability to use multiple virtual desktops to organize and separate workspaces

Integration with Apple Ecosystem


o Integration with other Apple devices, such as iPhones and iPads, through features
such as AirDrop and Continuity
o Access to the App Store, which offers a large collection of high-quality, Mac-
compatible apps
o Integration with Apple's cloud storage solution, iCloud, allowing users to access and
sync data across all their Apple devices

Security and Privacy

o Built-in security features, such as FileVault encryption, to protect users' data and
privacy
o Regular software updates to address security vulnerabilities and improve the
overall stability of the operating system.

Difference between Windows, Linux and MacOs


Linux Windows macOs
Hardware Versatile, can run on Very versatile Proprietary
quality low-spec PCs hardware, very high-
end
Cost Mostly free, some Freemium, accessing Free but comes on
distros have paid all features costs an expensive
versions approximately $150 hardware
Software Open-source Unparalleled Has its own app
Compatibility substitutes for ecosystem
proprietary software
Ease of Requires some Easy Very easy
Installation computing
knowledge
Security and The safest and most Generally great, Very good, requires
Stability stable OS requires plenty of only a few periodic
frequent updates updates
Ease of Use Ease of use Simple to use Very easy to use
determined by distro
Experiment-02

Aim- Study of various functions of Operating System.

1. Process Management in OS (Operating Systems):

Every software that runs on a computer, whether in the background or in the frontend, is a
process. In an operating system, process management os( Operating
System) refers to the set of activities involved in creating, scheduling, and
terminating processes . The operating system determines which processes have access to
the processor and how much processing time every process has in a multiprogramming
environment.

The operating system kernel manages the processes and resources of the system . For
processor management, the OS performs the following tasks:

 It keeps track of how processes are progressing.


 A traffic controller is a program that accomplishes this duty.
 Allocates a processor-based CPU to a process. When a process is no longer needed,
the processor is deallocated.

Process Scheduling
Process scheduling is an essential part of a Multiprogramming operating systems. It refers
to the mechanism that the operating system uses to determine which process to
execute next. Multiprogramming operating systems allow more than one process to be
loaded into the executable memory at a time and the loaded process shares the CPU using
time multiplexing.

There are different scheduling algorithms that an operating system can use to
schedule processes. Here are some of the commonly used scheduling algorithms:

1. First-Come, First-Served (FCFS): This is the simplest scheduling


algorithm, where the process that arrives first is executed first. FCFS is
non-preemptive, which means that once a process starts executing, it will
continue to run until it completes or waits for an I/O operation.
2. Shortest Job First (SJF): SJF is a preemptive scheduling algorithm that
selects the process with the shortest burst time. The burst time is the
amount of time a process takes to complete its execution. SJF minimizes
the average waiting time of the processes.
3. Round Robin (RR): RR is a preemptive scheduling algorithm that
allocates a fixed time slice to each process in a circular queue. If a process
does not complete its execution within the allocated time slice, it is
preempted and added to the end of the queue. RR provides fair allocation
of CPU time to all processes and avoids starvation.
4. Priority Scheduling: This scheduling algorithm assigns a priority to each
process, and the process with the highest priority is executed first.
Priority can be determined based on the proc ess type, importance, or
resource requirements.

Purpose of CPU scheduling


The purpose of CPU scheduling is as follows:

 Proper utilization of CPU. Since the proper utilization of the CPU is necessary. Therefore,
the OS makes sure that the CPU should be as busy as possible.
 Since every device should get a chance to use the processor. Hence, the OS makes sure
that the devices get fair processor time.
 Increasing the efficiency of the system.

Process Management in Windows Operating System

In Windows operating system, process management involves several key components and
mechanisms:

Process Creation: When a program is executed, Windows creates a process to manage its
execution. This involves allocating memory space, initializing data structures, and creating
a primary thread for execution.

Process Address Space: Each process in Windows has its own virtual address space,
which includes sections such as code, data, stack, and heap. Processes are isolated from
each other, preventing direct access to each other's memory.

Thread Management: Threads are the smallest units of execution within a process.
Windows allows processes to create multiple threads to perform concurrent tasks. The
operating system schedules threads for execution based on priority and other factors.

Scheduling: Windows uses a priority-based scheduling algorithm to determine which


thread should execute next. Threads with higher priority levels are given preference over
threads with lower priority levels. Windows dynamically adjusts thread priorities based on
factors such as CPU usage and I/O activity.
Context Switching: When Windows switches between executing threads, it performs a
context switch. This involves saving the state of the currently executing thread (such as
CPU registers and program counter) and restoring the state of the thread that will begin
execution.

Process Termination: Processes in Windows can terminate voluntarily by calling exit() or


encountering an error. Additionally, the operating system can terminate processes forcibly
in response to user actions or system events.

Process Communication and Synchronization: Windows provides mechanisms for inter-


process communication (IPC) and synchronization. This allows processes to exchange data
and coordinate their activities. Examples of IPC mechanisms in Windows include named
pipes, sockets, and shared memory.

Process Monitoring and Management: Windows provides tools for monitoring and
managing processes. Task Manager is a built-in utility that allows users to view information
about running processes, CPU usage, memory usage, and other system resources.
Administrators can use Task Manager to terminate or prioritize processes as needed.

2. Memory Management in Operating System

The operating system manages the Primary Memory or Main Memory. Main memory is
made up of a large array of bytes or words where each byte or word is assigned a certain
address. Main memory is fast storage and it can be accessed directly by the CPU.

For a program to be executed, it should be first loaded in the main memory. When the
program is completed, the memory region is released and can be used by other programs.
Therefore, there can be more than one program present at a time. Hence, it is required to
manage the memory.

Operating System performs the following activities for Memory Management:

 It keeps track of primary memory, i.e., which bytes of memory are used by which
user program. The memory addresses that have already been allocated and the
memory addresses of the memory that has not yet been used.
 In multiprogramming, the OS decides the order in which processes are granted
memory access, and for how long.
 It Allocates the memory to a process when the process requests it and deallocates
the memory when the process has terminated or is performing an I/O operation.

The common memory management techniques used by OS are Partioning and Virtual
Memory.
a) Partitioning
 The total memory is divided into various partitions of same sizeor different
sizes.
 This helps to accommodate number of programs in the memory.
 The partition can be fixed i.e. memory is allocated when a program is loaded
on to the memory.
 The later approach causes less wastage of memory but in due course of time,
it may become fragmented.

b) Virtual Memory

A computer can address more memory than the amount physically installed on the
system. This extra memory is actually called virtual memory and it is a section of a hard
disk that's set up to emulate the computer's RAM.
The main visible advantage of this scheme is that programs can be larger than physical
memory. Virtual memory serves two purposes. First, it allows us to extend the use of
physical memory by using disk. Second, it allows us to have memory protection, because
each virtual address is translated to a physical address.

Memory Management in Windows Operating System

Memory management in the Windows operating system involves several core components
and techniques:

Virtual Memory: Windows uses virtual memory to abstract physical RAM and provide
each process with its own virtual address space. This allows processes to operate as if they
have access to a large, contiguous block of memory, even if physical RAM is limited.

Address Translation: The Memory Manager translates virtual addresses used by


processes into physical addresses in RAM. It maintains a mapping between virtual and
physical addresses using data structures like page tables.

Memory Protection: Windows employs memory protection mechanisms to prevent


unauthorized access to memory regions. Each page of memory can be marked with access
control settings, such as read-only, read/write, or no access. This helps to isolate processes
and prevent one process from interfering with the memory of another.

Page File: Windows uses a page file (swap file) as a complement to physical memory.
When physical memory becomes scarce, the Memory Manager swaps out less frequently
used pages from RAM to the page file, freeing up space for other processes.
Page Replacement: In cases where physical memory is full, the Memory Manager uses
page replacement algorithms (e.g., Least Recently Used) to determine which pages to swap
out to the page file. This ensures that the most essential and frequently accessed pages
remain in RAM.

Working Sets: Windows manages the working sets of processes, which represent the set of
memory pages actively used by a process. The Memory Manager dynamically adjusts the
size of a process's working set based on its memory usage patterns and system resource
availability.

Memory-Mapped Files: Windows supports memory-mapped files, allowing processes to


map a file or portion of a file directly into memory. This enables efficient file I/O operations
and seamless integration of file data with memory.

Dynamic Memory Allocation: Windows provides APIs such as HeapAlloc() and


VirtualAlloc() for dynamic memory allocation within processes. These APIs allow processes
to request memory from the system as needed, and the Memory Manager handles the
allocation and management of memory blocks.

3. File Management in Operating System


File management in operating system is formally defined as manipulating files in
a computer system, which includes creating, modifying, and deleting files.
Therefore, file management is one of th e simple but crucial features offered by
the operating system. The operating system’s file management function entails
software that handles or maintains files (binary, text, PDF, docs, audio,
video, etc.) included in computer software.

The operating system’s file system can manage single and group files in a
computer system. The operating system’s file management manages all of the files
on the computer system with different extensions(such as .exe, .pdf, .txt,
.docx, etc.).

The features of File Management in an Operating System are

1. Providing security to application software and system.


2. Memory management
3. Disk management.
4. I/O operations.
5. File management, etc

So, file management is one of the basic but important features of the operating
system.
File Management in Windows Operating System

The Windows operating system manages files through its File System, which is
primarily the New Technology File System (NTFS) in modern versions like
Windows 10 and Windows 11. Here's how file management works in Windows:

File System: Windows uses the New Technology File System (NTFS) as its
primary file system. NTFS offers features such as file and folder permissions,
encryption, compression, disk quotas, and more. These features help manage files
securely and efficiently.

File Explorer: File Explorer is the graphical user interface through which users
interact with files and folders in Windows. It allows users to navigate through the
file system, create, copy, move, rename, and delete files and folders.

File Attributes: Each file in Windows has attributes such as read -only, hidden,
system, and archive. These attributes help in managing and organizing files based
on their properties.

Folder Structure: Windows organizes files and folders hierarchically in a folder


structure. Users can create folders to organize their files logically and access
them easily.

File Operations: Windows supports various file operations such as copying,


moving, renaming, and deleting files and folders. Users can perform these
operations using File Explorer or through command-line utilities like copy, move,
rename, and del.

Search: Windows provides a search feature that allows users to quickly find files
and folders based on their names, content, properties, and metadata.

Recycle Bin: When users delete files and folders in Windows, they are typically
moved to the Recycle Bin rather than being permanently deleted. This allows
users to restore deleted files if needed.

File Associations: Windows associates specific file types with corresp onding
applications. For example, double-clicking a .docx file may open it in Microsoft
Word by default.

File Permissions: NTFS allows administrators to set permissions on files and


folders to control who can access, modify, or delete them. This helps in m anaging
file security and access control.

Backup and Restore: Windows provides built-in tools for backing up and
restoring files and folders, allowing users to protect their data against accidental
loss or corruption.y
4. Device Management in Operating System

The process of implementation, operation, and maintenance of a device by an


operating system is called device management. When we use computers we will
be having various devices connected to our system like mouse, keyboard, scanner,
printer, and pen drives. So all these are the devices and the operating system acts
as an interface that allows the users to communicate with these devices. An
operating system is responsible for successfully establishing the connection
between these devices and the system. Th e operating system uses the concept of
drivers for establishing a connection between these devices with the system.

Functions of Device Management

1. Keeps track of all devices and the program which is responsible to perform
this is called the I/O controller.
2. Monitoring the status of each device such as storage drivers, printers, and
other peripheral devices.
3. Enforcing preset policies and taking a decision on which process gets the
device when and for how long.
4. Allocates and deallocates the device in an efficient way.

Features of Device Management in the Operating System:

Some important features of device management in operating systems are listed below:

 The operating system’s device management system automatically detects new hardware
devices as they are connected to the system, and configures them to work with the
operating system.
 Device drivers are software components that allow the operating system to communicate
with hardware devices.
 The device management system is responsible for allocating system resources such as
memory, processor time, and input/output bandwidth to hardware devices and
applications that use them.
 The device management system controls access to hardware devices to prevent conflicts
and ensure that only authorized applications and users can access the devices.

Device Management in Windows Operating System

Device management in the Windows operating system involves several key components
and processes:
Device Drivers: Windows uses device drivers to facilitate communication between
hardware devices and the operating system. These drivers translate hardware-specific
commands into a language that the operating system can understand and vice versa.

Device Manager: Device Manager is a built-in Windows tool that allows users to view and
manage hardware devices installed on their computer. It provides information about
device status, drivers, and allows users to update, disable, or uninstall devices as needed.

Plug and Play (PnP): Windows supports Plug and Play technology, which enables the
automatic detection and configuration of hardware devices as they are connected or
disconnected from the computer. PnP allows for seamless integration of new devices
without requiring manual configuration.

Device Installation Policies: Windows allows administrators to define policies governing


how devices are installed and configured on computers. These policies control factors such
as driver installation sources, user permissions for installing devices, and driver signing
requirements.

Device Classes and Interface Classes: Windows categorizes devices into classes based on
their functionality and characteristics. Device classes provide a standardized way of
interacting with similar types of devices, while interface classes define common
programming interfaces for device drivers.

Power Management: Windows includes power management features that allow users to
optimize the power consumption of hardware devices, particularly in portable devices like
laptops and tablets. Power management settings can be adjusted to extend battery life and
reduce energy consumption.

Device Policies and Restrictions: Administrators can enforce device policies and
restrictions using Group Policy settings to control which devices users can connect to their
computers, restrict access to specific device types, or prevent unauthorized access to
sensitive hardware components.

Windows Management Instrumentation (WMI): WMI is a management infrastructure


provided by Windows for querying and managing system information, including hardware
devices and their properties. Administrators can use WMI to automate device management
tasks and monitor device status across an enterprise network.
Experiment-3

Aim- Study of WINDOWS 2000 operating system and latest version


of Windows.

Windows 2000

Windows 2000 is an operating system (OS) developed by Microsoft. Released


in February 2000, it was designed to run application programs, store files,
support networking and run multimedia features. Extended support for
Windows 2000 was discontinued in 2010.

Windows 2000 was a direct successor to Windows NT 4.0 and was followed
by Windows XP. This version of Windows OS offered better and more stable
support for computer hardware than prior Microsoft OSes.

Previously called Windows NT 5.0, Microsoft emphasized that Windows 2000


was evolutionary and built on NT technology, which was a combination of
Windows NT Workstation and Windows NT Server. Windows 2000 was
designed to appeal to small and medium-sized businesses (SMBs) and
professional users, as well as to the more technical and larger business market
for which NT was designed.

Features of Windows 2000 OS


1. Kernel and Architecture: Windows 2000 featured the Windows NT 5.0
kernel, providing a more stable and robust foundation than previous
versions. It supported symmetric multiprocessing (SMP) and
introduced improvements in memory management, process scheduling,
and system reliability.

2. Active Directory: One of the significant innovations was the


introduction of Active Directory, a centralized directory service for
managing network resources. Active Directory simplified the
administration of networks, providing a hierarchical structure for
organizing and managing users, computers, and other network
resources.

3. Plug and Play: Windows 2000 enhanced hardware support through


improved Plug and Play capabilities. This made it easier for users to
install and configure hardware devices, reducing the need for manual
intervention.

4. User Interface: The graphical user interface (GUI) in Windows 2000


closely resembled that of Windows 98, providing users with a familiar
environment. The Start menu, taskbar, and Explorer interface were
refined for a more intuitive user experience.

5. NTFS File System Improvements: Windows 2000 introduced


improvements to the NTFS (New Technology File System) file system,
including support for disk quotas, encryption, and improved file-level
security. These enhancements contributed to better data management
and security.

6. Compatibility: Windows 2000 aimed to improve compatibility with


existing software and hardware. It included a compatibility mode to run
older Windows applications and supported a wide range of hardware
devices.

7. Networking and Internet Integration: The operating system


emphasized networking capabilities and Internet integration. It
included built-in support for TCP/IP, the dominant protocol for the
internet, and introduced features like Internet Connection Sharing for
easier home network setup.

8. Security Enhancements: Windows 2000 implemented various security


improvements, such as encrypted file systems, Kerberos authentication,
and more granular access controls. These measures aimed to enhance
the overall security posture of the operating system.

9. Professional and Server Editions: Windows 2000 was available in two


main editions: Windows 2000 Professional for desktops and laptops
and Windows 2000 Server for server environments. The server edition
included additional features and capabilities tailored for enterprise-
level tasks.

System Requirements
Windows 2000 is an operating system developed by Microsoft and released in
2000. Here is a brief overview of the system requirements for Windows 2000:

1. Processor (CPU): Pentium 133 MHz or equivalent


2. Memory (RAM): 64 MB
3. Hard Disk Space: 2 GB of free space
4. Display: VGA or higher resolution monitor with 256 colors
5. Graphics: DirectX 7.0a-compatible graphics card
6. Input Devices: Keyboard and mouse (or another pointing device)
7. CD-ROM Drive: Required for installation from CD.
8. Network Adapter: Required for network installation and connectivity.
9. Other:
a. Microsoft Mouse or compatible pointing device
b. Sound card (for multimedia applications)
c. Modem or network adapter for Internet connectivity

History and Versions


Windows 2000 was a significant operating system released by Microsoft on
February 17, 2000. It marked a major step forward regarding stability,
security, and enterprise functionality compared to its predecessor, Windows
NT 4.0. Here's a brief overview of its history and versions:

1. Windows NT 3.1 to 4.0:


a. Before Windows 2000, Microsoft developed the Windows NT series, starting
with version 3.1 in 1993.
b. Windows NT 4.0, released in 1996, was the immediate precursor to Windows
2000 and introduced the NTFS file system and Active Directory.

2. Windows 2000 Versions:


a. Windows 2000 came in several editions, with the main ones being:
b. Windows 2000 Professional: Designed for business desktops and laptops.
c. Windows 2000 Server: Targeted at small to medium-sized businesses,
offering server capabilities.
d. Windows 2000 Advanced Server: Provided additional features and
scalability for larger enterprises.
e. Windows 2000 Datacenter Server: Designed for high-end, mission-critical
applications.

3. Life Cycle:
a. Mainstream support for Windows 2000 ended on June 30, 2005.
b. Extended support, including security updates and patches, continued until
July 13, 2010.

4. Legacy and Impact:


a. Windows 2000 laid the foundation for future Microsoft operating systems,
notably the Windows XP series.
b. Many businesses and organizations continued to use Windows 2000 for
several years due to its stability, even after the release of newer versions.

Windows 11
Windows 11 is the latest major release of Microsoft's Windows NT operating
system, released on October 5, 2021. It succeeded Windows 10 (2015) and is
available for free for any Windows 10 devices that meet the new Windows 11
system requirements.

Windows 11 features major changes to the Windows shell influenced by the


canceled Windows 10X, including a redesigned Start menu, the replacement of
its "live tiles" with a separate "Widgets" panel on the taskbar, the ability to
create tiled sets of windows that can be minimized and restored from the
taskbar as a group, and new gaming technologies inherited from Xbox Series X
and Series S such as Auto HDR and DirectStorage on compatible hardware.
Internet Explorer (IE) has been replaced by the Chromium-based Microsoft
Edge as the default web browser, like its predecessor, Windows 10, and
Microsoft Teams is integrated into the Windows shell.

Features of Windows 11 OS
Redesigned Start Menu: Windows 11 introduces a centered Start Menu,
which is more simplified and visually appealing compared to Windows 10.

Taskbar Enhancements: The taskbar in Windows 11 has been redesigned to


be more centered and streamlined, with new icons and features like snap
layouts and virtual desktops.

Snap Layouts and Snap Groups: Windows 11 introduces new ways to


organize and snap windows, making it easier to multitask and arrange
windows on your screen.

Enhanced Window Management: Windows 11 includes features like Snap


Assist, which suggests other windows to snap when you resize a window, and
Desktops, which allow you to create separate virtual desktops for different
tasks.

Microsoft Store Redesign: The Microsoft Store in Windows 11 has been


revamped with a new design and better support for apps, including support
for both traditional Win32 apps and modern UWP (Universal Windows
Platform) apps.

Improved Gaming Features: Windows 11 includes enhancements for


gaming, such as Auto HDR (High Dynamic Range) support, DirectStorage for
faster loading times, and integration with Xbox Game Pass.

Better Touch, Pen, and Voice Input: Windows 11 includes improvements


for touch, pen, and voice input, making it easier to interact with your device
using different input methods.

Updated Taskbar: The taskbar in Windows 11 has been redesigned to be


more centered and streamlined, with new icons and features like snap layouts
and virtual desktops.

System Requirements
Processor: 1 gigahertz (GHz) or faster with 2 or more cores on a compatible
64-bit processor or System on a Chip (SoC).
RAM: 4 gigabyte (GB).

Storage: 64 GB or larger storage device Note: See below under “More


information on storage space to keep Windows 11 up-to-date” for more
details.

System firmware: UEFI, Secure Boot capable. Check here for information on
how your PC might be able to meet this requirement.

TPM: Trusted Platform Module (TPM) version 2.0. Check here for instructions
on how your PC might be enabled to meet this requirement.

Graphics card: Compatible with DirectX 12 or later with WDDM 2.0 driver.

Display: High definition (720p) display that is greater than 9” diagonally, 8


bits per colour channel.

Internet connection and Microsoft account: Windows 11 Pro for personal


use and Windows 11 Home require internet connectivity and a Microsoft
account during initial device set-up.

Difference between Windows 2000 and Windows 11

Feature Windows 2000 Windows 11


Browser Internet browser Internet explorer (hidden)
5.01 browser Microsoft Edge Browser.
User Interface Classic Windows Centered Start menu, redesigned
taskbar
Compatibility Limited for modern Supports Windows 10
Software/hardware applications, improved hardware
compatibility
Performance Tailored for older Optimization for modern
hardware hardware
System Lower compared to Slightly higher than windows 10,
requirements modern OS focus on newer hardware.
Security Basic for its time. Further enhanced with windows,
bit locker improvement.
Experiment-4(a)

Aim- Implementation of First Come First Serve scheduling


algorithm.

#include<stdio.h>

void findWaitingTime(int processes[], int n, int bt[], int wt[]) {

wt[0] = 0;

for (int i = 1; i < n; i++)

wt[i] = bt[i - 1] + wt[i - 1];

void findTurnAroundTime(int processes[], int n, int bt[], int wt[], int tat[]) {

for (int i = 0; i < n; i++)

tat[i] = bt[i] + wt[i];

void findAverageTime(int processes[], int n, int bt[]) {

int wt[n], tat[n], total_wt = 0, total_tat = 0;

findWaitingTime(processes, n, bt, wt);

findTurnAroundTime(processes, n, bt, wt, tat);

printf("Process Burst Time Waiting Time Turnaround Time\n");


for (int i = 0; i < n; i++) {

total_wt = total_wt + wt[i];

total_tat = total_tat + tat[i];

printf(" %d \t\t %d \t\t %d \t\t %d \n", i + 1, bt[i], wt[i], tat[i]);

printf("\nAverage waiting time = %.2f", (float)total_wt / (float)n);

printf("\nAverage turnaround time = %.2f", (float)total_tat / (float)n);

int main() {

int processes[] = {1, 2, 3};

int n = sizeof(processes) / sizeof(processes[0]);

int burst_time[] = {10, 5, 8};

findAverageTime(processes, n, burst_time);

return 0;

Output-
Experiment-4(d)

Aim- Implementation of Robin Round scheduling algorithm.

#include <stdio.h>

void findWaitingTime(int processes[], int n, int bt[], int wt[], int quantum) {

int rem_bt[n];

for (int i = 0; i < n; i++)

rem_bt[i] = bt[i];

int t = 0;

while (1) {

int done = 1;

for (int i = 0; i < n; i++) {

if (rem_bt[i] > 0) {

done = 0; // There is a pending process

if (rem_bt[i] > quantum) {

t += quantum;

rem_bt[i] -= quantum;

}
else {

t = t + rem_bt[i];

wt[i] = t - bt[i];

rem_bt[i] = 0;

if (done == 1)

break;

void findTurnAroundTime(int processes[], int n, int bt[], int wt[], int tat[]) {

// Turnaround time = Burst time + Waiting time

for (int i = 0; i < n; i++)

tat[i] = bt[i] + wt[i];

void findAverageTime(int processes[], int n, int bt[], int quantum) {

int wt[n], tat[n], total_wt = 0, total_tat = 0;


findWaitingTime(processes, n, bt, wt, quantum);

findTurnAroundTime(processes, n, bt, wt, tat);

printf("Processes Burst time Waiting time Turnaround time\n");

for (int i = 0; i < n; i++) {

total_wt += wt[i];

total_tat += tat[i];

printf(" %d\t\t%d\t\t%d\t\t%d\n", i + 1, bt[i], wt[i], tat[i]);

printf("\nAverage waiting time = %.2f", (float)total_wt / (float)n);

printf("\nAverage turnaround time = %.2f", (float)total_tat / (float)n);

int main() {

int processes[] = {1, 2, 3};

int n = sizeof(processes) / sizeof(processes[0]);

int burst_time[] = {10, 5, 8};

int quantum = 2;

findAverageTime(processes, n, burst_time, quantum);

return 0;
}
Experiment-4(b)

Aim- Implementation of Shortest Job First scheduling algorithm.

#include <stdio.h>

#include <stdlib.h>

// Structure to represent a process

struct Process {

int pid; // Process ID

int burst_time; // Burst time

int waiting_time; // Waiting time

};

// Function to compare burst times for sorting

int compare(const void *a, const void *b) {

return ((struct Process *)a)->burst_time - ((struct Process *)b)->burst_time;

// Function to perform SJF scheduling

void sjfScheduling(struct Process processes[], int n) {

int total_waiting_time = 0;

printf("Process\tBurst Time\tWaiting Time\n");


// Sort processes based on burst time

qsort(processes, n, sizeof(struct Process), compare);

// Calculate waiting time and total waiting time

for (int i = 0; i < n; i++) {

printf("%d\t\t%d\t\t%d\n", processes[i].pid, processes[i].burst_time,


total_waiting_time);

total_waiting_time += processes[i].burst_time;

// Calculate average waiting time

printf("Average Waiting Time: %.2f\n", (float)total_waiting_time / n);

int main() {

// Example processes

struct Process processes[] = {

{1, 6, 0},

{2, 8, 0},

{3, 7, 0},

{4, 3, 0}

};
int n = sizeof(processes) / sizeof(processes[0]);

// Perform SJF scheduling

sjfScheduling(processes, n);

return 0;

Output-
Experiment-4(e)

Aim- Implementation of Priority scheduling algorithm.

#include <stdio.h>

#include <stdlib.h>

// Structure to represent a process

struct Process {

int pid; // Process ID

int burst_time; // Burst time

int priority; // Priority of the process

int waiting_time; // Waiting time

};

// Function to compare priorities for sorting

int compare_priority(const void *a, const void *b) {

return ((struct Process *)a)->priority - ((struct Process *)b)->priority;

// Function to perform Priority Scheduling

void priorityScheduling(struct Process processes[], int n) {


int total_waiting_time = 0;

printf("Process\tBurst Time\tPriority\tWaiting Time\n");

// Sort processes based on priority

qsort(processes, n, sizeof(struct Process), compare_priority);

// Calculate waiting time and total waiting time

for (int i = 0; i < n; i++) {

printf("%d\t\t%d\t\t%d\t\t%d\n", processes[i].pid, processes[i].burst_time,


processes[i].priority, total_waiting_time);

total_waiting_time += processes[i].burst_time;

// Calculate average waiting time

printf("Average Waiting Time: %.2f\n", (float)total_waiting_time / n);

int main() {

// Example processes

struct Process processes[] = {

{1, 6, 2, 0},
{2, 8, 1, 0},

{3, 7, 3, 0},

{4, 3, 4, 0}

};

int n = sizeof(processes) / sizeof(processes[0]);

// Perform Priority Scheduling

priorityScheduling(processes, n);

return 0;

Output-
Experiment-4(c)

Aim- Implementation of Shortest Remaining Time Next (SRTN)


algorithm.

#include <stdio.h>

#include <stdlib.h>

struct Process {

int process_id;

int arrival_time;

int burst_time;

int remaining_time;

int completion_time;

};

void swap(struct Process *xp, struct Process *yp) {

struct Process temp = *xp;

*xp = *yp;

*yp = temp;

void sort_by_arrival_time(struct Process *processes, int n) {


int i, j;

for (i = 0; i < n-1; i++) {

for (j = 0; j < n-i-1; j++) {

if (processes[j].arrival_time > processes[j+1].arrival_time) {

swap(&processes[j], &processes[j+1]);

int main() {

int n, i, time = 0, total_burst_time = 0;

printf("Enter the number of processes: ");

scanf("%d", &n);

struct Process *processes = (struct Process*)malloc(n * sizeof(struct


Process));

for (i = 0; i < n; i++) {

printf("Enter arrival time and burst time for process %d: ", i+1);

scanf("%d %d", &processes[i].arrival_time, &processes[i].burst_time);

processes[i].process_id = i + 1;
processes[i].remaining_time = processes[i].burst_time;

total_burst_time += processes[i].burst_time;

sort_by_arrival_time(processes, n);

printf("\nGantt Chart:\n");

printf("0 ");

while (time < total_burst_time) {

int min_remaining_time = total_burst_time + 1;

int min_index = -1;

for (i = 0; i < n; i++) {

if (processes[i].arrival_time <= time && processes[i].remaining_time <


min_remaining_time && processes[i].remaining_time > 0) {

min_remaining_time = processes[i].remaining_time;

min_index = i;

if (min_index == -1) {

printf("IDLE ");

time++;
} else {

printf("P%d ", processes[min_index].process_id);

processes[min_index].remaining_time--;

time++;

if (processes[min_index].remaining_time == 0) {

processes[min_index].completion_time = time;

printf("\n\nProcess\tArrival Time\tBurst Time\tCompletion


Time\tTurnaround Time\tWaiting Time\n");

float total_turnaround_time = 0, total_waiting_time = 0;

for (i = 0; i < n; i++) {

int turnaround_time = processes[i].completion_time -


processes[i].arrival_time;

int waiting_time = turnaround_time - processes[i].burst_time;

total_turnaround_time += turnaround_time;

total_waiting_time += waiting_time;

printf("%d\t%d\t\t%d\t\t%d\t\t%d\t\t\t%d\n",
processes[i].process_id, processes[i].arrival_time, processes[i].burst_time,
processes[i].completion_time, turnaround_time, waiting_time);

}
printf("\nAverage Turnaround Time: %.2f\n", total_turnaround_time / n);

printf("Average Waiting Time: %.2f\n", total_waiting_time / n);

free(processes);

return 0;

Output-
Experiment-9

Aim- WAP to implement Banker’s algorithm for Deadlock


Avoidance.

#include <stdio.h>

// Number of processes

#define P 5

// Number of resources

#define R 3

// Function to find the need of each process

void calculateNeed(int need[P][R], int maxm[P][R], int allot[P][R])

for (int i = 0; i < P; i++)

for (int j = 0; j < R; j++)

need[i][j] = maxm[i][j] - allot[i][j];

// Function to check if the system is in a safe state

int isSafe(int processes[], int avail[], int maxm[][R], int allot[][R])

int need[P][R];

calculateNeed(need, maxm, allot);


int finish[P] = {0};

int work[R];

for (int i = 0; i < R; i++)

work[i] = avail[i];

int count = 0;

while (count < P)

int found = 0;

for (int p = 0; p < P; p++)

if (!finish[p])

int j;

for (j = 0; j < R; j++)

if (need[p][j] > work[j])

break;

if (j == R)

for (int k = 0; k < R; k++)

work[k] += allot[p][k];

finish[p] = 1;

found = 1;
count++;

if (!found)

break;

return count == P;

int main()

int processes[] = {0, 1, 2, 3, 4};

int avail[] = {3, 3, 2};

int maxm[][R] = {{7, 5, 3},

{3, 2, 2},

{9, 0, 2},

{2, 2, 2},

{4, 3, 3}};

int allot[][R] = {{0, 1, 0},

{2, 0, 0},
{3, 0, 2},

{2, 1, 1},

{0, 0, 2}};

if (isSafe(processes, avail, maxm, allot))

printf("System is in a safe state.\n");

else

printf("System is not in a safe state.\n");

return 0;

Output-
Experiment-5

Aim- Execution of UNIX/Linux Commands.

Basic Linux Commands-

Basic commands in Linux are essential for navigating the file system, managing files and
directories, and performing various task. Here’s a list of fundamental linux commands.

Date- The date command in linux is used to display or set the system data and time. It can
be used to display the current date and time in various formats, as well as to set the system
date and time.

Cal- the ‘al’ command in linux is used to display a calendar for a specific month and year. By
default, it display the current month. You can specify a month and year as arguments to the
‘cal’ command to display the calendar for that specific month. For example, ‘cal 5 2024’ will
display the calendar for May 2024.

Echo- the echo command in linux is used to display text or variables on the terminal. It
simply outputs the text or variables passed to it as assignment.

Ls- the ‘ls’ command in linux is used to list files and directories in the current directory. It
displays the names of files and directories in the specified directory.

Lp- the lp command in linux is used to send files to a printer for printing. It allows you to
specify various printing options such as printer destination, number of copies, page ranges,
and print filters. It is part of the common linux printing system which is the printing system
used to most linux distributions.

Who- the who command in linux displays information about users who are currently
logged in, including their username, terminal, and login time. Ir can also show details about
system’s run-level.

Uptime- the uptime command in linux displays the current time, how long the system has
been running , the number of users currently logged in, and the system load averages for
the past 1, 5 and 15 minutes. It is a quick way to check the system’s uptime and load status.
Hostname- the hostname command in linux is used to view or set the hostname of the
system. When used without any argument it displays the current hostname of the system. If
you provide an argument, it sets the hostname to the specified value temporarily.

Bc- the ‘bc’ command in linux is a calculator that allows you to perform arithmetic
calculations at the command line. It stands for “basic calculator”. It can handle basic
mathematical functions, as well as more complex calculations using variables and
functions.

Output-

Basic Manipulation Commands-

Cat- The ‘cat’ command in linux is short for “concatenate” and is used to display the
contents of one or more file to the standard output(usually the terminals). It can also be
used to concatenate files by combining them and sending the output to a new file or to the
standard output.
Grep- ‘grep’ is a command-line utility in Linux and Linux-like operating systems used for
searching plain text data sets for lines that matches a regular expression. It stands for
“Global Regular Expression Print”. It is commonly used to search files for pattern of text or
to filter the output of other commands.

Rm- The ‘rm’ command in Linux is used to remove directories. It stands for “remove”. Be
cautions when using it because it permanently deletes the separated files files or
directories and they cannot be easily recovered.

Touch- The ‘touch’ command in Linux is used to create new empty files or update the time
stamps of existing files. If the file doesn’t exist, touch creates an empty file with the
specified name. if the file already exist, ‘touch’ updates the access and modification time to
the current time, unless specified otherwise.

Cp- The ‘cp’ command in Linux is used to copy files and directories from one location to
another. It duplicates file and directories while preserving their permissions, timestamps
and ownerships.

mv- The ‘mv’ command in Linux is used to move files or directories from one location to
another. It can also be used to rename files or directories.

Cut- The ‘cut’ command in Linux is used to extract sections from each line of input data and
write the result to standard output. It’s particularly useful for working with files that have
fixed-width columns or delimiters such as CSU files with ‘cut’. You can specify which
sections of each line you want to extract based on byte positions, character positions, or
field positions.

Head, tail- the ‘head’ and ‘tail’ commands are used in Linux to display the beginning or end
of a text file, respectively.
Head- displays the first few lines of a file (by default the first 10 lines).
Tail- displays the last few lines of a file (by default, the last 10 lines).

Chmod- ‘chmod’ is a command in Linux and Unix like operating system that is used to
change the permissions of files or directories. It stands for ‘change mode’ with ‘chmod’. You
can modify the read, write and execute permissions for the owner of the file. It is commonly
used to control who can read, write or execute file or directory.

Output-
System calls –

Fork()- Fork refers to a system call used by processes to create a new process. When a
process causes “fork”, it is essential creates a copy of itself, resulting in two processes, the
parent process and the child process.

Exec()-It is used to execute a command replacing the current process. When you run a
command with ‘exec’, it replaces the current shell process with the specified command,
effectively ending the shell session after their command finishes execution.

Getpid- It is used to retrieve the process ID (PID) of the current process. Typically, it is
used with C programs to obtain the PID dynamically during runtime.

Exit- The exit command in Linux is used to close the current shell or terminal session.
When you type ‘exit’ and press enter, the shell session will terminate, and you will be
returned to the previous environment, such as the desktop or another shell if you are in a
nested shell session.

Wait- The wait command is used to wait for the complication of background process. It
pauses the execution of a shell script until all background jobs or specified job ID’s have
finished executing. This command is particularly useful in shell scripting to ensure
sequential execution of commands.
Close- The close command in Linux is typically used to close file descriptor. It is system call
used by programs to release resources associated with a file descriptor after it is no longer
needed. This helps in managing system resources efficiently.

Opendir- The ‘opendir’ command is not a stand alone command in Linux. Instead, it is a
function used in programming with C language to open a directory stream for reading. It is
part of the C standard library and is used to interact with directories within C programs.

Closedir-In Linux, the ‘closedir’ command is used to close a directory stream opened by the
‘opendir’ command. It releases any resources associated with the directory streams. This
command is typically stored you’ve finished reading from a directory using ‘readdir’ and
‘closedir’ ensure proper cleanup.

Output-
Experiment-6

Write a shell programs to-

a) Check if the given number is even or odd.

#!/usr/bin/bash

read -p 'Enter the number: ' num

if (($num %2 ==0))

then echo 'The number is even'

else echo 'The Number is Odd'

fi

b) Check if the given year is leap or not.

#!/usr/bin/bash

read -p 'Enter the year: ' year

if (((($year %4 ==0) && (($year %100 !=0)))) || (($year % 400 ==0)))

then echo 'The year is leap'

else echo 'The year is not leap'

fi
c) Find factorial of a number.

#!/bin/bash

read -p "Enter a number:" num

factorial=1

if [ $num -lt 0 ]; then

echo "Factorial is not defined for negative numbers."

elif [ $num -eq 0 ]; then

echo "Factorial of 0 is 1."

else

for (( i=1; i<=num; i++ )); do

factorial=$((factorial * i))

done

echo "Factorial of $num is $factorial."

Fi

d) Swap two numbers.

#!/usr/bin/bash

read -p 'Enter the first number: ' num1

read -p 'Enter the second number: ' num2

echo "Before swap: first num= $num1 , second num= $num2 "
temp=$num1

num1=$num2

num2=$temp

echo "After swap: first num= $num1 , second num= $num2 "

e) Check if the number is negative or positive.

read -p "Enter a number: " num

if [ $num -gt 0 ];

then echo "The number is Positive"

else echo "The number is Negative"

fi

f) Convert uppercase letters in a string to a lowercase


letters.

read -p "Enter a string consisting of uppercase letters: " str

echo "the converted string is " ${str,,}


g) Print prime numbers from 1 to 50.

prime_numbers=""

for ((i=2; i<=50; i++))

do

is_prime=true

for ((j=2; j<i; j++))

do

if [ $((i%j)) -eq 0 ]

then

is_prime=false

break

fi

done

if $is_prime

then

prime_numbers+=" $i"

fi

done

echo "Prime numbers from 1 to 50: $prime_numbers"


h) Calculate the sum of digits of a number.

read -p "Enter the number: " num

sum=0

temp=$((num))

while [ $temp -gt 0 ]; do

sum=$(( sum + temp%10))

temp=$((temp/10))

done

echo "The sum of digits of $num is: $sum"

i) Find smallest and largest number in a list of numbers.

read -p "Enter a list of space-separated integers: " -a array

smallest=${array[0]}

largest=${array[0]}

for i in "${array[@]}"; do

if [[ "$i" -lt "$smallest" ]]; then

smallest="$i"

fi

if [[ "$i" -gt "$largest" ]]; then

largest="$i"
fi

done

echo "Smallest number in list: $smallest"

echo "Largest number in list: $largest"

j) Calculate average of 10 numbers.

sum=0

cnt=0

while [ $cnt -lt 10 ]; do

read -p "Enter a number: " num

sum=$((sum + num))

cnt=$((cnt + 1))

done

avg=$((sum / cnt))

echo "Average of the 10 numbers: $avg"


Experiment-10
Aim- WAP to implement algorithm for deadlock detection.

#include <stdio.h>

#define MAX_PROCESSES 10

#define MAX_RESOURCES 10

int processes; // Number of processes

int resources; // Number of resources

int allocation[MAX_PROCESSES][MAX_RESOURCES];

int request[MAX_PROCESSES][MAX_RESOURCES];

int available[MAX_RESOURCES];

int finish[MAX_PROCESSES];

int work[MAX_RESOURCES];

// Function to initialize the system

void initialize() {

printf("Enter the number of processes: ");

scanf("%d", &processes);

printf("Enter the number of resources: ");

scanf("%d", &resources);

printf("Enter the allocation matrix:\n");

for (int i = 0; i < processes; i++) {

for (int j = 0; j < resources; j++) {

scanf("%d", &allocation[i][j]);
}

printf("Enter the request matrix:\n");

for (int i = 0; i < processes; i++) {

for (int j = 0; j < resources; j++) {

scanf("%d", &request[i][j]);

printf("Enter the available resources vector:\n");

for (int i = 0; i < resources; i++) {

scanf("%d", &available[i]);

// Function to detect deadlock

int detect_deadlock() {

// Initialize finish array

for (int i = 0; i < processes; i++) {

finish[i] = 0;

// Initialize work array

for (int i = 0; i < resources; i++) {

work[i] = available[i];

// Find a process which can finish

int count = 0;
while (count < processes) {

int found = 0;

for (int i = 0; i < processes; i++) {

if (!finish[i]) {

int j;

for (j = 0; j < resources; j++) {

if (request[i][j] > work[j])

break;

if (j == resources) {

// Process i can finish

for (int k = 0; k < resources; k++) {

work[k] += allocation[i][k];

finish[i] = 1;

found = 1;

count++;

// If no process found which can finish, deadlock detected

if (!found) {

return 1; // Deadlock detected

}
return 0; // No deadlock

int main() {

initialize();

if (detect_deadlock()) {

printf("Deadlock detected.\n");

} else {

printf("No deadlock detected.\n");

return 0;

Output-
Experiment-7
Aim- WAP to implement producer consumer problem using
semaphores.

#include <stdio.h>

#include <stdlib.h>

#include <pthread.h>

#define BUFFER_SIZE 5

#define MAX_ITEMS 5

int buffer[BUFFER_SIZE];

int in = 0;

int out = 0;

int produced_count = 0;

int consumed_count = 0;

pthread_mutex_t mutex;

pthread_cond_t full;

pthread_cond_t empty;

void* producer(void* arg) {

int item = 1;

while (produced_count < MAX_ITEMS) {


pthread_mutex_lock(&mutex);

while (((in + 1) % BUFFER_SIZE) == out) {

pthread_cond_wait(&empty, &mutex);

buffer[in] = item;

printf("Produced: %d", item);

item++;

in = (in + 1) % BUFFER_SIZE;

produced_count++;

pthread_cond_signal(&full);

pthread_mutex_unlock(&mutex);

pthread_exit(NULL);

void* consumer(void* arg) {

while (consumed_count < MAX_ITEMS) {

pthread_mutex_lock(&mutex);

while (in == out) {

pthread_cond_wait(&full, &mutex);

}
int item = buffer[out];

printf("Consumed: %d", item);

out = (out + 1) % BUFFER_SIZE;

consumed_count++;

pthread_cond_signal(&empty);

pthread_mutex_unlock(&mutex);

pthread_exit(NULL);

int main() {

pthread_t producerThread, consumerThread;

pthread_mutex_init(&mutex, NULL);

pthread_cond_init(&full, NULL);

pthread_cond_init(&empty, NULL);

pthread_create(&producerThread, NULL, producer, NULL);

pthread_create(&consumerThread, NULL, consumer, NULL);

pthread_join(producerThread, NULL);

pthread_join(consumerThread, NULL);

pthread_mutex_destroy(&mutex);

thread_cond_destroy(&empty);
return 0;

Output-
Experiment-8
Aim- WAP to implement dining philosoper’s problem.
#include<stdio.h>

#include<stdlib.h>

#include<pthread.h>

#include<semaphore.h>

#include<unistd.h>

sem_t room; // counting semaphore

sem_t chopstick[5]; // binary semaphore

void * philosopher(void *);

void eat(int);

void eat(int phil)

printf("\nPhilosopher %d is eating",phil);

int main()

int i,a[5];

pthread_t tid[5]; // creation of threads refering to 5 philosophers


sem_init(&room,0,4); // initializations of semaphore varring from 0 to 4.

for(i=0;i<5;i++)

sem_init(&chopstick[i],0,1); //initializations of binary semaphore .

for(i=0;i<5;i++){

a[i]=i;

pthread_create(&tid[i],NULL,philosopher,(void *)&a[i]); // creation of


philosopher and assigning it a number.

for(i=0;i<5;i++)

pthread_join(tid[i],NULL); // waits until a thread gets terminated

void * philosopher(void * num)

int phil=*(int *)num;

sem_wait(&room); // semaphore function to checks if resources are


available.

printf("\nPhilosopher %d has entered room",phil);

sem_wait(&chopstick[phil]); // semaphore function to checks if chopstick is


available.

sem_wait(&chopstick[(phil+1)%5]);

eat(phil);
sleep(2);

printf("\nPhilosopher %d has finished eating",phil);

sem_post(&chopstick[(phil+1)%5]); // gives confirmation if semophore is released


successfully

sem_post(&chopstick[phil]);

sem_post(&room);

Output-
Experiment-11
Aim- WAP to create threads and synchronize them.
#include <stdio.h>

#include <stdlib.h>

#include <pthread.h>

#define NUM_THREADS 2

int sharedData = 0;

pthread_mutex_t mutex;

void *threadFunction(void *threadID) {

long tid;

tid = (long)threadID;

// Acquire lock

pthread_mutex_lock(&mutex);

// Critical section

sharedData++;

printf("Thread %ld incremented sharedData to %d\n", tid, sharedData);

// Release lock

pthread_mutex_unlock(&mutex);

pthread_exit(NULL);

int main() {

pthread_t threads[NUM_THREADS];
int rc;

long t;

// Initialize mutex

pthread_mutex_init(&mutex, NULL);

// Create threads

for (t = 0; t < NUM_THREADS; t++) {

printf("Creating thread %ld\n", t);

rc = pthread_create(&threads[t], NULL, threadFunction, (void *)t);

if (rc) {

printf("ERROR; return code from pthread_create() is %d\n", rc);

exit(-1);

// Join threads

for (t = 0; t < NUM_THREADS; t++) {

pthread_join(threads[t], NULL);

// Destroy mutex

pthread_mutex_destroy(&mutex);

printf("Final sharedData value: %d\n", sharedData);

pthread_exit(NULL);

Output-
Experiment-12
Aim- WAP to implement memory allocation method for fixed
partitions using first/worst/best fit.
#include <stdio.h>

#include <stdlib.h>

#define MEMORY_SIZE 1000

#define NUM_PARTITIONS 5

// Structure to represent a partition

typedef struct Partition {

int id;

int size;

int isOccupied;

} Partition;

Partition memoryPartitions[NUM_PARTITIONS];

int memory[MEMORY_SIZE];

// Initialize memory partitions

void initializeMemoryPartitions() {

int i;

for (i = 0; i < NUM_PARTITIONS; i++) {

memoryPartitions[i].id = i;

memoryPartitions[i].size = MEMORY_SIZE / NUM_PARTITIONS;

memoryPartitions[i].isOccupied = 0;
}

// Display memory layout

void displayMemoryLayout() {

int i;

printf("Memory Layout:\n");

for (i = 0; i < NUM_PARTITIONS; i++) {

printf("Partition %d: [%s]\n", memoryPartitions[i].id, memoryPartitions[i].isOccupied ?


"Occupied" : "Free");

printf("\n");

// First Fit Allocation

int firstFit(int processSize) {

int i;

for (i = 0; i < NUM_PARTITIONS; i++) {

if (!memoryPartitions[i].isOccupied && memoryPartitions[i].size >= processSize) {

memoryPartitions[i].isOccupied = 1;

return i;

return -1;

// Best Fit Allocation

int bestFit(int processSize) {


int i, bestFitPartition = -1, minSize = MEMORY_SIZE;

for (i = 0; i < NUM_PARTITIONS; i++) {

if (!memoryPartitions[i].isOccupied && memoryPartitions[i].size >= processSize &&


memoryPartitions[i].size < minSize) {

bestFitPartition = i;

minSize = memoryPartitions[i].size;

if (bestFitPartition != -1) {

memoryPartitions[bestFitPartition].isOccupied = 1;

return bestFitPartition;

// Worst Fit Allocation

int worstFit(int processSize) {

int i, worstFitPartition = -1, maxSize = 0;

for (i = 0; i < NUM_PARTITIONS; i++) {

if (!memoryPartitions[i].isOccupied && memoryPartitions[i].size >= processSize &&


memoryPartitions[i].size > maxSize) {

worstFitPartition = i;

maxSize = memoryPartitions[i].size;

if (worstFitPartition != -1) {

memoryPartitions[worstFitPartition].isOccupied = 1;

}
return worstFitPartition;

// Release memory partition

void releasePartition(int partitionId) {

if (partitionId >= 0 && partitionId < NUM_PARTITIONS) {

memoryPartitions[partitionId].isOccupied = 0;

int main() {

int choice, processSize, partitionId;

// Initialize memory partitions

initializeMemoryPartitions();

do {

printf("1. Allocate Memory (First Fit)\n");

printf("2. Allocate Memory (Best Fit)\n");

printf("3. Allocate Memory (Worst Fit)\n");

printf("4. Release Memory\n");

printf("5. Display Memory Layout\n");

printf("6. Exit\n");

printf("Enter your choice: ");

scanf("%d", &choice);

switch (choice) {
case 1:

printf("Enter process size: ");

scanf("%d", &processSize);

partitionId = firstFit(processSize);

if (partitionId != -1) {

printf("Memory allocated successfully in partition %d\n", partitionId);

} else {

printf("Memory allocation failed!\n");

break;

case 2:

printf("Enter process size: ");

scanf("%d", &processSize);

partitionId = bestFit(processSize);

if (partitionId != -1) {

printf("Memory allocated successfully in partition %d\n", partitionId);

} else {

printf("Memory allocation failed!\n");

break;

case 3:

printf("Enter process size: ");

scanf("%d", &processSize);

partitionId = worstFit(processSize);

if (partitionId != -1) {
printf("Memory allocated successfully in partition %d\n", partitionId);

} else {

printf("Memory allocation failed!\n");

break;

case 4:

printf("Enter partition ID to release: ");

scanf("%d", &partitionId);

releasePartition(partitionId);

printf("Memory released successfully from partition %d\n", partitionId);

break;

case 5:

displayMemoryLayout();

break;

case 6:

printf("Exiting...\n");

break;

default:

printf("Invalid choice!\n");

} while (choice != 6);

return 0;

}
Output-
Experiment-13
Aim- WAP to implement page replacement algorithms
a) FIFO b) LRU c) LFU d) Optimal
#include <stdio.h>

#include <stdlib.h>

#define NUM_FRAMES 3

#define NUM_PAGES 15

// Page replacement algorithms

void fifo(int pages[], int n) {

int frames[NUM_FRAMES];

int frameIndex = 0;

int pageFaults = 0;

int i, j;

for (i = 0; i < NUM_FRAMES; i++) {

frames[i] = -1; // Initialize frames as empty

for (i = 0; i < n; i++) {

int page = pages[i];

int found = 0;

// Check if page is already in memory

for (j = 0; j < NUM_FRAMES; j++) {

if (frames[j] == page) {

found = 1;
break;

if (!found) {

frames[frameIndex] = page;

frameIndex = (frameIndex + 1) % NUM_FRAMES;

pageFaults++;

printf("Page %d -> ", page);

for (j = 0; j < NUM_FRAMES; j++) {

printf("%d ", frames[j]);

printf("\n");

printf("Total page faults (FIFO): %d\n", pageFaults);

void lru(int pages[], int n) {

int frames[NUM_FRAMES];

int frameIndex = 0;

int pageFaults = 0;

int i, j;

for (i = 0; i < NUM_FRAMES; i++) {

frames[i] = -1; // Initialize frames as empty

}
int *recentlyUsed = (int *)malloc(NUM_FRAMES * sizeof(int));

for (i = 0; i < NUM_FRAMES; i++) {

recentlyUsed[i] = 0; // Initialize recently used array

for (i = 0; i < n; i++) {

int page = pages[i];

int found = 0;

// Check if page is already in memory

for (j = 0; j < NUM_FRAMES; j++) {

if (frames[j] == page) {

found = 1;

recentlyUsed[j] = i + 1; // Update recently used time

break;

if (!found) {

int leastUsedIndex = 0;

for (j = 1; j < NUM_FRAMES; j++) {

if (recentlyUsed[j] < recentlyUsed[leastUsedIndex]) {

leastUsedIndex = j;

frames[leastUsedIndex] = page;

recentlyUsed[leastUsedIndex] = i + 1; // Update recently used time

pageFaults++;
}

printf("Page %d -> ", page);

for (j = 0; j < NUM_FRAMES; j++) {

printf("%d ", frames[j]);

printf("\n");

free(recentlyUsed);

printf("Total page faults (LRU): %d\n", pageFaults);

void lfu(int pages[], int n) {

// LFU not implemented in this example

printf("LFU page replacement algorithm not implemented.\n");

void optimal(int pages[], int n) {

// Optimal not implemented in this example

printf("Optimal page replacement algorithm not implemented.\n");

int main() {

int pages[NUM_PAGES] = {7, 0, 1, 2, 0, 3, 0, 4, 2, 3, 0, 3, 2, 1, 2};

printf("FIFO page replacement algorithm:\n");

fifo(pages, NUM_PAGES);
printf("\nLRU page replacement algorithm:\n");

lru(pages, NUM_PAGES);

printf("\nLFU page replacement algorithm:\n");

lfu(pages, NUM_PAGES);

printf("\nOptimal page replacement algorithm:\n");

optimal(pages, NUM_PAGES);

return 0;

Output-
Experiment-14
Aim- WAP to implement file allocation strategies for student details
(Roll No, Name, Branch)
a) Sequential b) Indexed c) Linked
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#define MAX_STUDENTS 100

#define MAX_NAME_LENGTH 50

#define MAX_BRANCH_LENGTH 20

// Structure for student record

typedef struct {

int rollNo;

char name[MAX_NAME_LENGTH];

char branch[MAX_BRANCH_LENGTH];

} Student;

// Sequential file allocation

void sequentialFile(Student students[], int numStudents) {

FILE *file = fopen("sequential.txt", "w");

if (file == NULL) {

printf("Error opening file!\n");


return;

for (int i = 0; i < numStudents; i++) {

fprintf(file, "%d %s %s\n", students[i].rollNo, students[i].name, students[i].branch);

fclose(file);

printf("Sequential file written successfully!\n");

// Indexed file allocation

void indexedFile(Student students[], int numStudents) {

FILE *file = fopen("indexed.txt", "w");

FILE *indexFile = fopen("index.txt", "w");

if (file == NULL || indexFile == NULL) {

printf("Error opening file!\n");

return;

fprintf(indexFile, "RollNo Offset\n");

int offset = 0;

for (int i = 0; i < numStudents; i++) {

fprintf(file, "%d %s %s\n", students[i].rollNo, students[i].name, students[i].branch);

fprintf(indexFile, "%d %d\n", students[i].rollNo, offset);


offset += sizeof(Student);

fclose(file);

fclose(indexFile);

printf("Indexed file written successfully!\n");

// Linked file allocation

void linkedFile(Student students[], int numStudents) {

FILE *file = fopen("linked.bin", "wb");

if (file == NULL) {

printf("Error opening file!\n");

return;

for (int i = 0; i < numStudents; i++) {

fwrite(&students[i], sizeof(Student), 1, file);

fclose(file);

printf("Linked file written successfully!\n");

int main() {
Student students[MAX_STUDENTS];

int numStudents;

printf("Enter the number of students: ");

scanf("%d", &numStudents);

if (numStudents <= 0 || numStudents > MAX_STUDENTS) {

printf("Invalid number of students!\n");

return 1;

for (int i = 0; i < numStudents; i++) {

printf("Enter details for student %d:\n", i + 1);

printf("Roll No: ");

scanf("%d", &students[i].rollNo);

printf("Name: ");

scanf("%s", students[i].name);

printf("Branch: ");

scanf("%s", students[i].branch);

// Perform file allocation

sequentialFile(students, numStudents);

indexedFile(students, numStudents);

linkedFile(students, numStudents);
return 0;

Output-
Experiment-15
Aim- WAP to implement Disk scheduling algorithms
a) FCFS b) SCAN c) C-SCAN
#include <stdio.h>

#include <stdlib.h>

#define MAX_REQUESTS 100

#define CYLINDERS 200

// Function to sort disk requests in ascending order

void sortRequests(int requests[], int numRequests) {

int i, j, temp;

for (i = 0; i < numRequests - 1; i++) {

for (j = 0; j < numRequests - i - 1; j++) {

if (requests[j] > requests[j + 1]) {

temp = requests[j];

requests[j] = requests[j + 1];

requests[j + 1] = temp;

// FCFS disk scheduling algorithm

void fcfs(int requests[], int numRequests, int start) {

int totalMovement = 0;
printf("FCFS Disk Scheduling Algorithm:\n");

printf("Head Movement Order: ");

for (int i = 0; i < numRequests; i++) {

printf("%d ", requests[i]);

totalMovement += abs(requests[i] - start);

start = requests[i];

printf("\nTotal Head Movement: %d\n\n", totalMovement);

// SCAN disk scheduling algorithm

void scan(int requests[], int numRequests, int start) {

int totalMovement = 0;

int direction = 1; // 1 for right, -1 for left

int current = start;

int i, j;

sortRequests(requests, numRequests);

printf("SCAN Disk Scheduling Algorithm:\n");

printf("Head Movement Order: ");

// Move right until the end

for (i = start; i <= CYLINDERS; i++) {

for (j = 0; j < numRequests; j++) {

if (requests[j] == i) {

printf("%d ", requests[j]);

totalMovement += abs(requests[j] - current);


current = requests[j];

if (i == CYLINDERS && direction == 1) {

direction = -1;

i = 0;

printf("\nTotal Head Movement: %d\n\n", totalMovement);

// C-SCAN disk scheduling algorithm

void cscan(int requests[], int numRequests, int start) {

int totalMovement = 0;

int current = start;

int i, j;

sortRequests(requests, numRequests);

printf("C-SCAN Disk Scheduling Algorithm:\n");

printf("Head Movement Order: ");

// Move right until the end

for (i = start; i <= CYLINDERS; i++) {

for (j = 0; j < numRequests; j++) {

if (requests[j] == i) {

printf("%d ", requests[j]);

totalMovement += abs(requests[j] - current);

current = requests[j];
}

// Move back to the beginning

for (i = 0; i < start; i++) {

for (j = 0; j < numRequests; j++) {

if (requests[j] == i) {

printf("%d ", requests[j]);

totalMovement += abs(requests[j] - current);

current = requests[j];

printf("\nTotal Head Movement: %d\n\n", totalMovement);

int main() {

int requests[MAX_REQUESTS];

int numRequests, start;

printf("Enter the number of disk requests: ");

scanf("%d", &numRequests);

if (numRequests <= 0 || numRequests > MAX_REQUESTS) {

printf("Invalid number of requests!\n");

return 1;

}
printf("Enter the starting position of the head: ");

scanf("%d", &start);

printf("Enter the disk requests:\n");

for (int i = 0; i < numRequests; i++) {

scanf("%d", &requests[i]);

fcfs(requests, numRequests, start);

scan(requests, numRequests, start);

cscan(requests, numRequests, start);

return 0;

Output-

You might also like