Indira Gandhi Delhi Technical
University for Women
(established by the Govt. NCT of Delhi vide Delhi Act 09 of 2012)
(Formerly Indira Gandhi Institute of Technology)
Kashmiri Gate, Delhi – 110006
OPERATING SYSTEM
Submitted to:
Ms. Nidhi Arora
Assistant Professor
IT Department
Submitted By:
Sapna Morya
MCA (Sem-1)
OPERATING STSTEM ASSIGNMENT
ASSIGNMENT - 1
Q1. Define Operating System.
Ans. An Operating System (OS) is a system software that serves as a link between the user
and the computer hardware. It provides a platform on which application programs can run,
making the overall system easier and more efficient to use.
The OS ensures smooth interaction by managing communication between hardware
components and software applications. It hides the complexity of the underlying hardware
and gives the user a simple way to operate the computer.
Operating systems can be of different types such as:
Batch Operating System – Executes jobs in batches.
Time-sharing Operating System – Enables multiple users to work simultaneously on
a single system.
Real-time Operating System – Used where instant response is required, such as in
robotics and embedded systems.
Distributed Operating System – Connects multiple computers and makes them work
as a single system.
Mobile Operating System – Specially designed for handheld devices, e.g., Android
and iOS.
Examples: popular operating systems include Windows, Linux, macOS, Android, and iOS.
Q2. Functions of Operating System.
Ans. The Operating System acts as the manager of the entire computer system, handling
hardware and software resources. Its major functions are:
1. Process Management
A process is a program in execution.
The OS is responsible for creating, scheduling, and terminating processes.
It ensures proper allocation of CPU time using scheduling algorithms (e.g., FCFS,
Round Robin).
It also provides mechanisms for synchronization, communication, and deadlock
handling among processes.
2. Memory Management
The OS manages the system’s main memory (RAM).
It keeps track of which part of memory is in use and which is free.
It allocates memory to processes when required and deallocates it after completion.
Advanced techniques like paging, segmentation, and virtual memory are used to
optimize memory utilization.
3. File Management
Data on secondary storage (like hard disks) is organized into files and directories.
The OS provides facilities for creating, reading, writing, deleting, and protecting
files.
It also manages permissions (read, write, execute) and maintains the file system
structure.
4. Device Management
The OS acts as a mediator between hardware and user programs.
Each device has a device driver which is managed by the OS.
It allocates devices to processes, manages queues for device requests, and ensures
smooth data transfer.
5. Input/Output (I/O) Management
I/O operations are slower compared to CPU, so the OS handles buffering, caching,
and spooling.
It ensures data is properly exchanged between CPU, memory, and peripheral devices.
6. Security and Protection
Protects data and resources from unauthorized access.
Provides mechanisms like user authentication (passwords, biometrics), access
control, and encryption.
Prevents malicious programs or users from damaging the system.
7. User Interface
The OS provides ways for the user to interact with the computer:
o CLI (Command Line Interface) – e.g., MS-DOS, Linux terminal.
o GUI (Graphical User Interface) – e.g., Windows, macOS.
It hides hardware complexity and offers a user-friendly environment.
Q3. Need of Operating System.
Ans. An Operating System (OS) is essential because it acts as a bridge between the user and
the computer hardware. Without an OS, a user would have to directly interact with
hardware components using machine-level instructions, which is extremely difficult and
inefficient.
The main needs for an OS are:
1. Ease of Use – It provides a simple interface (GUI or CLI) for users to operate the
computer without dealing with hardware complexity.
2. Resource Management – The OS manages system resources like CPU, memory,
storage, and devices so that they are used efficiently and fairly among multiple
applications.
3. Multitasking – It enables multiple programs and users to work on the system at the
same time without conflict.
4. Hardware Control – The OS controls and coordinates input/output devices
(keyboard, mouse, printer, etc.) so the user does not need to manage them manually.
5. Security & Protection – It protects data and resources from unauthorized access and
ensures privacy and system integrity.
6. Error Handling – Detects and resolves errors in programs or hardware to ensure
smooth functioning of the system.
7. Communication – Provides a platform for processes to communicate with each other
(Inter-Process Communication) and for users to communicate with the computer.
Q4. List types of Operating system in tabular form with columns: Sr. No, Name of OS,
Versions/flavours/distribution, Vendor, target market place.
Ans.
Sr. no. Name of OS Versions/Flavours Vendor Market Place
01. Windows OS Windows 7,8,10,11 Microsoft Personal computers
02. Linux OS Ubuntu, Red Hat Open source Server, Desktops
03. Mac OS Ventura, Sonoma Apple Inc. Apple laptops
04. Android OS Android 11,12,13,14 Google Smartphones, IoT
05. iOS iOS 15,16,17 Apple Inc. iPhone, iPads
06. Unix OS Solaris, HP-UX AT&T, Oracle Server, Workstation
07. Real Time OS VxWorks, QNX Wind River Robotics, Defence
08. Disk OS Ms DOS, Free DOS Microsoft Early PCs
ASSIGNMENT – 2
Q1. Write Introduction, architecture, history, features and versions of Unix.
Ans. Introduction
UNIX is a multiuser, multitasking operating system originally developed in the 1960s
and 1970s at AT&T’s Bell Labs.
It is written mostly in the C programming language, making it portable across
different machines.
UNIX became the foundation for many modern operating systems like Linux, BSD,
macOS, and Android (indirectly).
Motto: “Do one thing, and do it well.”
2. Architecture of UNIX
UNIX architecture is layered and consists of three main components:
1. Kernel
o Core of UNIX.
o Manages hardware, memory, processes, file system, and system calls.
2. Shell
o Interface between user and kernel.
o Accepts commands, interprets them, and passes them to kernel.
o Examples: Bourne Shell (sh), Bash, C shell, Korn shell.
3. Utilities / Applications
o Standard programs and tools that users run for tasks (e.g., ls, cp, grep, editors
like vi).
o Also includes user applications built on top of UNIX.
3. History of UNIX
1969 → Developed at AT&T Bell Labs by Ken Thompson, Dennis Ritchie, and others.
1971 → First edition of UNIX released.
1973 → Rewritten in C language, making it portable.
Late 1970s–1980s → Spread widely in universities and research centers.
1983 → UNIX System V released (commercial version by AT&T).
1990s → Many variants emerged (Solaris, HP-UX, AIX, BSD).
Today → UNIX principles live on in Linux, macOS, and other modern OS.
4. Features of UNIX
1. Multiuser – Multiple users can access the system simultaneously.
2. Multitasking – Can execute multiple processes at the same time.
3. Portability – Written in C, so easily adaptable to different hardware.
4. Security – Provides file permissions and access control.
5. Hierarchical File System – Organizes data in a tree structure starting from root (/).
6. Shell and Utilities – Powerful command-line interface with scripting capabilities.
7. Networking – Built-in tools for communication and networking.
8. Device Independence – Devices treated as files for uniform access.
5. Versions of UNIX
Over time, many versions/flavours of UNIX were developed:
Version / Flavour Vendor / Developer Notes
UNIX System V AT&T Commercial version, widely used
in enterprises
BSD (Berkeley Software University of California, Academic version, led to FreeBSD,
Distribution) Berkeley OpenBSD, NetBSD
Solaris Sun Microsystems (later Enterprise servers and
Oracle) workstations
AIX IBM Enterprise version for IBM servers
HP-UX Hewlett-Packard Enterprise-grade UNIX for HP
machines
macOS (Darwin) Apple Based on BSD UNIX
Linux (inspired) Linus Torvalds & Not UNIX, but UNIX-like (POSIX
community compliant)
Q2. Write Introduction, architecture, history, features and versions of Linux.
Ans. 1. Introduction
Linux is a free, open-source, Unix-like operating system kernel, first released in 1991
by Linus Torvalds.
It follows UNIX principles and is POSIX-compliant.
Linux is the foundation for many distributions (distros) such as Ubuntu, Fedora,
Debian, Red Hat, Arch Linux, etc.
It is widely used in servers, desktops, supercomputers, embedded devices, Android
phones, and IoT systems.
Core philosophy: open source, community-driven development, security, and
portability.
2. Architecture of Linux
Linux architecture is modular and layered.
1. Hardware Layer
o Physical components: CPU, memory, I/O devices.
2. Kernel
o Heart of Linux, manages process scheduling, memory management, device
drivers, file system, and system calls.
o Types: Monolithic kernel (Linux is monolithic but modular).
3. System Libraries
o Provide standard functions (e.g., GNU C Library glibc) to access kernel
features.
4. System Utilities
o Programs that manage system configuration and day-to-day tasks.
5. Shell
o Command-line interpreter between user and kernel.
o Examples: Bash, Zsh, Tcsh, Fish.
6. Application Programs
o User-level software (editors, browsers, office tools, games, etc.).
3. History of Linux
1969 → UNIX developed at Bell Labs.
1983 → GNU Project started by Richard Stallman (to build a free UNIX-like OS).
1991 → Linus Torvalds, a student in Finland, released the first version of the Linux
kernel.
1992 → Linux released under GNU General Public License (GPL) → made it free and
open-source.
1990s onward → Various Linux distributions (Debian, Red Hat, SUSE, Slackware)
developed.
2000s onward → Linux became dominant in servers, supercomputers, mobile
(Android), and cloud computing.
Today → Powers majority of internet servers, most supercomputers, Android OS, and
is widely used in DevOps, AI/ML, and IoT.
4. Features of Linux
1. Open Source – Source code is free to view, modify, and distribute.
2. Multiuser – Multiple users can use the system simultaneously.
3. Multitasking – Can run multiple processes at the same time.
4. Security – File permissions, SELinux, and user roles provide strong security.
5. Portability – Runs on almost every hardware platform (from mobiles to
supercomputers).
6. Networking – Strong networking and server capabilities (Apache, FTP, SSH, etc.).
7. Shell & Scripting – Powerful command-line tools and automation via shell scripts.
8. Hierarchical File System – Organizes files starting from root (/).
9. Stability and Performance – Rarely crashes, used in mission-critical systems.
10. Customizability – Highly configurable (different desktop environments, kernels,
shells).
5. Versions / Distributions of Linux
Sr. Distribution / Version Vendor / Target Use
No Community
1 Ubuntu Canonical Ltd. Beginners, desktops, servers,
cloud
2 Debian Debian Stable, research, development
Community
3 Fedora Red Hat Developers, bleeding-edge
Community features
4 Red Hat Enterprise Linux Red Hat (IBM) Enterprise servers, corporate IT
(RHEL)
5 CentOS / Rocky Linux Community-driven Enterprise, server replacement
for RHEL
6 openSUSE SUSE Community Developers, desktop and servers
Q3. Write Introduction, architecture, history, features and versions of Windows.
Ans. 1. Introduction
Windows is a proprietary operating system developed by Microsoft Corporation.
First launched in 1985 as a graphical operating environment on top of MS-DOS.
Known for its Graphical User Interface (GUI), user-friendliness, and widespread
adoption.
Used across personal computers, laptops, tablets, enterprise servers, and
embedded devices.
It has become the most popular desktop operating system worldwide due to its ease
of use, compatibility, and large software ecosystem.
2. Architecture of Windows
Windows OS follows a layered + modular architecture:
1. Hardware Layer
o Physical resources: CPU, memory, devices.
2. Kernel (Windows NT Kernel)
o Core of the OS, manages process scheduling, memory, device drivers, and
system calls.
3. Executive Services
o Provides system-level functions: object manager, process manager, I/O
manager, memory manager, security reference monitor.
4. System Libraries (DLLs)
o Dynamic Link Libraries (like [Link], [Link]) provide APIs for
application programs.
5. System Utilities & Services
o Background services and tools (task manager, registry, device manager).
6. User Interface (GUI + Shell)
o Windows Desktop, Start menu, taskbar, File Explorer.
7. Application Layer
o End-user applications like MS Office, browsers, games, etc.
3. History of Windows
1981 → Microsoft begins work on "Interface Manager".
1985 (Windows 1.0) → First version with GUI, ran on MS-DOS.
1987 (Windows 2.0) → Overlapping windows, better graphics.
1990 (Windows 3.0) → Became popular with improved performance, program
manager.
1995 (Windows 95) → Introduced Start Menu, Taskbar, Plug & Play, 32-bit support.
1998 (Windows 98) → USB support, better Internet Explorer integration.
2000 (Windows 2000) → Business-oriented, NT-based stability.
2001 (Windows XP) → Highly successful, modern GUI, stability, security.
2007 (Windows Vista) → New Aero interface but criticized for performance.
2009 (Windows 7) → Stable, popular OS with improved UI.
2012 (Windows 8/8.1) → Introduced Metro UI, touchscreen support.
2015 (Windows 10) → Universal apps, Cortana, modern updates.
2021 (Windows 11) → Latest version, centered taskbar, enhanced performance,
hybrid work focus.
4. Features of Windows
1. Graphical User Interface (GUI) – Easy to use with windows, icons, menus.
2. Multitasking – Can run multiple applications simultaneously.
3. Networking Support – Built-in LAN, Wi-Fi, internet features.
4. Backward Compatibility – Supports older applications.
5. Security Features – User authentication, encryption, firewall, BitLocker.
6. Plug and Play (PnP) – Auto-detection and installation of hardware devices.
7. Extensive Software Support – Huge ecosystem of applications and games.
8. File System Support – FAT32, NTFS, exFAT.
9. User Management – Multi-user accounts, parental control, access restrictions.
10. Regular Updates – Patches, service packs, and feature updates via Windows Update.
5. Versions of Windows
Sr. Version / Edition Release Year Target Market
No.
1 Windows 1.0 1985 Basic GUI over MS-DOS
2 Windows 3.x 1990 Personal computers
3 Windows 95 1995 Home and business desktops
4 Windows 98 1998 Internet-enabled PCs
5 Windows 2000 2000 Business / Enterprise
6 Windows XP 2001 Home, Professional, Enterprise
7 Windows Vista 2007 Home and business PCs
Q4. Similarities and difference between unix, linux, windows.
Ans. Similarities:
1. Operating System Role → All manage hardware resources, provide user interfaces,
and run applications.
2. Multi-tasking → All support running multiple programs simultaneously.
3. Networking → Provide built-in networking and internet capabilities.
4. Security → Support authentication, file permissions, and access control.
5. Programming Support → Allow software development in multiple languages (C, C++,
Java, Python, etc.).
6. File Systems → Manage files in hierarchical directory structures.
7. GUI & CLI → Provide both graphical user interfaces and command-line interfaces.
Aspect UNIX Linux Windows
Origin Developed in 1969 Developed in 1991 by Developed by Microsoft in
at AT&T Bell Labs Linus Torvalds (open- 1985
source clone of UNIX)
Type Proprietary (though Open-source, free, Proprietary, commercial
some variants are community-driven software
commercial open
systems)
Kernel Monolithic Monolithic (with Hybrid kernel
modular support)
Source Closed (except some Open-source (anyone Closed-source
Code open UNIX variants) can modify)
User Mostly CLI (with Both CLI & GUI Primarily GUI, with
Interface some GUI variants) (GNOME, KDE, etc.) PowerShell/Command
Prompt
Cost Expensive Free (some paid Paid (requires license)
(commercial enterprise distributions
licenses) like RHEL, SUSE)
Hardware Traditionally used in Runs on almost all Designed mainly for PCs,
Support mainframes, servers hardware (PCs, servers, laptops, tablets
mobiles)
Security Very secure (strict Highly secure (open- Comparatively less secure
permissions, stable) source, fast patches) (more prone to
malware/viruses)
Target Servers, Servers, Personal computers,
Market workstations, supercomputers, business desktops, gaming
scientific computing desktops, embedded
devices
ASSIGNMENT – 3
Q1. Installation process of LINUX.
Ans. The process of installing Linux generally involves the following steps:
1. Prepare Installation Media
Download a Linux distribution ISO image (e.g., Ubuntu, Fedora, Debian, Red Hat).
Create a bootable USB/DVD using tools like Rufus, BalenaEtcher, or UNetbootin.
2. Boot from Installation Media
Insert the bootable USB/DVD into the computer.
Restart and enter the BIOS/UEFI setup (by pressing keys like F2, F12, Del, or Esc).
Set the boot order to boot from USB/DVD.
3. Start Linux Installer
The system will boot into the Linux installer or a live environment.
Select “Install Linux” from the menu.
4. Choose Language and Keyboard Layout
Select preferred language, region, and keyboard settings.
5. Disk Partitioning
Choose how Linux will be installed on the hard disk:
o Use entire disk (erases everything).
o Dual-boot (install alongside Windows).
o Manual partitioning (create /, /home, swap, etc. manually).
6. Select Installation Options
Choose whether to install third-party software, drivers, and updates.
Select desktop environment if asked (GNOME, KDE, XFCE, etc.).
7. Set User Details
Enter username, password, and hostname (computer name).
Optionally enable automatic login.
8. Installation Process
The installer copies system files to the hard disk, sets up partitions, and installs
bootloader (GRUB).
9. Reboot System
After installation is complete, remove the USB/DVD.
Restart the computer and boot into the newly installed Linux system.
10. Post-Installation Setup
Update the system (sudo apt update && sudo apt upgrade in Ubuntu).
Install required applications and drivers.
Customize settings (themes, networking, users, etc.)
Q2. Booting process of LINUX.
Ans. The booting process in Linux is the sequence of steps a computer follows to load the
operating system after power-on.
Steps of Linux Booting Process
1. BIOS/UEFI Initialization
o When the system is powered on, the BIOS/UEFI firmware runs a Power-On
Self Test (POST).
o It checks basic hardware (CPU, RAM, keyboard, disk controllers).
o Then it looks at the boot device order and loads the bootloader from the first
bootable device.
2. MBR / GPT and Bootloader Stage
o The MBR (Master Boot Record) in legacy systems or EFI partition (in UEFI)
contains the bootloader.
o Common Linux bootloaders: GRUB (GRand Unified Bootloader), LILO (older).
o Bootloader is responsible for loading the Linux kernel into memory.
o If multiple OS are installed (dual-boot), GRUB provides a menu to choose the
OS.
3. Kernel Loading
o The bootloader loads the Linux kernel (vmlinuz) into memory.
o It also loads the initramfs (initial RAM disk) which contains drivers/modules
required to mount the root filesystem.
o Kernel initializes system hardware and mounts the root filesystem.
4. Init Process (PID 1)
o After kernel initialization, the first process started is init (or systemd in
modern Linux).
o systemd is responsible for starting all other background services (daemons).
5. Runlevel / Target Initialization
o The system enters a runlevel/target (set of services to start):
Runlevel 3 → Multi-user (CLI, networking enabled).
Runlevel 5 → Multi-user with GUI (graphical login).
o systemd replaces old SysV runlevels with targets (e.g., [Link], multi-
[Link]).
6. Login Prompt / Display Manager
o Finally, the system provides either:
A login prompt (tty terminal) in CLI mode.
A graphical login screen (GDM, LightDM, etc.) in GUI mode.
o After successful login, the user gets access to the Linux shell or desktop
environment.
Q3. Login and shutdown process in LINUX.
Ans. 1. Login Process in Linux
When a user wants to access a Linux system:
1. Boot Completion – After booting, Linux shows either:
o Text Mode Login Prompt (tty), or
o Graphical Login Manager (like GDM, LightDM, KDM).
2. Entering Credentials – User provides:
o Username
o Password
3. Authentication –
o The system checks credentials against /etc/passwd and /etc/shadow.
o If password matches, access is granted. Otherwise, login fails.
4. Shell / Desktop Session –
o On successful login, the default shell (bash, zsh, etc.) or desktop
environment (GNOME, KDE, XFCE) is loaded.
o User can now execute commands or use applications.
2. Shutdown Process in Linux
Shutting down properly is important to avoid data corruption.
1. Initiate Shutdown Command – Common commands:
o shutdown -h now → Halt immediately.
o shutdown -r now → Reboot.
o poweroff → Power off.
o reboot → Restart system.
2. Systemd / Init Call –
o The shutdown command sends a signal to systemd (or init) to change system
state to shutdown/reboot target.
3. Stopping Processes –
o All running processes are terminated safely.
o Daemons (background services) are stopped.
4. Unmounting Filesystems –
o Mounted filesystems (/, /home, etc.) are unmounted.
o Any data in buffers/caches is written to disk to prevent data loss.
5. Kernel Halt / Reboot –
o Finally, the kernel halts the CPU (shutdown) or reboots the system.
Q4. External and internal commands in LINUX.
Ans. Internal Commands
Internal commands are built into the shell (like bash) itself.
They do not require a separate program file; the shell executes them directly.
They are faster since no new process is created.
Exist as part of the shell’s binary (e.g., /bin/bash).
Examples:
cd - Change directory
echo - Display message/text
pwd - Show current directory
set - Display/set shell variables
exit - Exit the shell
External Commands
External commands are stored as separate executable files in system directories
like /bin, /usr/bin, /sbin.
When executed, the shell creates a new process and runs the program file.
They are slightly slower than internal commands because a separate file must be
loaded.
Examples:
ls - List files in a directory
cp - Copy files
mv - Move/rename files
grep - Search patterns in files
find - Search for files
Q5. Shells of LINUX.
Ans. Shell in Linux
A Shell is a command-line interpreter in Linux/Unix.
It acts as a bridge between the user and the kernel.
The shell takes commands from the user, interprets them, and passes them to the
kernel for execution.
Apart from command execution, shells also support programming features
(variables, loops, conditional statements, etc.).
Common Shells in Linux
1. Bourne Shell (sh)
o The original Unix shell developed by Stephen Bourne (AT&T Bell Labs).
o Located at /bin/sh.
o Limited features (no history, no aliases).
2. Bash (Bourne Again Shell)
o Most common and default shell on many Linux distributions.
o Improved version of Bourne shell with features like command history, tab
completion, aliases, scripting.
o Located at /bin/bash.
3. C Shell (csh) / TENEX C Shell (tcsh)
o Syntax similar to the C programming language.
o Provides features like job control, command history.
o tcsh is an enhanced version of csh.
4. Korn Shell (ksh)
o Developed by David Korn (AT&T Bell Labs).
o Combines features of Bourne shell and C shell.
o Supports scripting, command editing, and job control.
5. Z Shell (zsh)
o An advanced shell with features of bash, ksh, and tcsh.
o Powerful customization, better autocompletion, spelling correction, and
plugin support.
o Often used with Oh-My-Zsh for developers.
6. Fish Shell (Friendly Interactive Shell)
o Modern shell with user-friendly features.
o Syntax highlighting, autosuggestions, and easier scripting.
Q6. File systems and directory structure of LINUX.
Ans. File System in Linux
The Linux file system is a way of organizing and storing data on disk.
Unlike Windows (which uses multiple drives like C:, D:), Linux has a single rooted
hierarchy starting from / (root directory).
Everything in Linux (files, directories, devices, processes) is treated as a file.
Common file system types: ext3, ext4, XFS, Btrfs, ReiserFS.
Linux Directory Structure (FHS – Filesystem Hierarchy Standard)
At the top level is / (root directory), and under it, various standard sub-directories exist:
Directory Purpose / Contents
/ Root directory (base of file system)
/bin Essential binary commands (e.g., ls, cp, mv, cat)
/sbin System binaries for administration (e.g., shutdown, mount)
/boot Bootloader files, Linux kernel, initrd images
/dev Device files (e.g., /dev/sda for disks, /dev/null)
Directory Purpose / Contents
/etc Configuration files (e.g., network, system, users)
/home User home directories (/home/user1, /home/user2)
/lib Shared libraries needed by system programs
/media Mount point for removable media (USB, CD/DVD)
/mnt Temporary mount point for filesystems
/opt Optional application software packages
/proc Virtual filesystem providing process and kernel info
/root Home directory of the root (admin) user
/run Runtime process data since last boot
/srv Data for services (e.g., web servers, FTP servers)
/sys Virtual filesystem giving info about kernel devices
/tmp Temporary files, cleared on reboot
/usr User programs, applications, libraries
/var Variable files (logs, spool files, caches, mail)
Q7. Editors in LINUX.
Ans. Editors in Linux
An editor in Linux is a program used to create, view, and modify text files. Editors are
mainly used for editing configuration files, scripts, source code, or documents.
Linux provides two types of editors:
1. Line Editors
Old style editors that allow editing line by line (no full screen interface).
Mostly used in very old Unix systems.
Example: ed, ex
2. Screen (Full-Screen) Editors
Modern editors that allow interactive editing on the entire screen.
Provide features like syntax highlighting, search/replace, copy-paste, undo-redo.
Widely used in development and system administration.
Popular Linux Editors:
Editor Type Features
vi (Visual Screen Oldest but powerful editor, available on all Linux systems. Works
Editor) editor in command mode and insert mode.
vim (Vi Screen Enhanced version of vi with syntax highlighting, multiple
Improved) editor windows, plugins.
Screen Simple and user-friendly editor, good for beginners. Commands
nano
editor shown at the bottom.
gedit GUI editor Default editor in GNOME desktop, user-friendly graphical
Editor Type Features
interface.
Screen Very powerful with built-in tools (mail, debugger, etc.), highly
emacs
editor customizable.
kate GUI editor KDE desktop environment text editor with advanced features.
ASSIGNMENT – 4
Q1. Explain and run these commands in terminal.
(a) Who
Shows which users are currently logged into the system.
(b)(i)Cal
Displays the calendar of the current month (by default).
(b)(ii) Cal -y
Shows the calendar of the complete current year with the current date highlighted.
(b)(iii) Cal [month] [year]
Shows calendar of selected month and year. For example, 'cal 09 2025' displays the calendar
for August 2000.
(b)(iv) Cal -3'
Shows calendar of previous, current and next month.
(b)(v)Cal -j
Shows the calendar of the current month in the Julian calendar format not in the
default Gregorian calendar format. In Julian calendar format, the date does not reset to 1
after every month's end i.e. after 31st Jan, Feb will start as 32nd Feb, not as 1st Feb. But in
the Gregorian calendar format, the date is reset to 1 after every month's end i.e after 31st
Jan, Feb will start as of 1st Feb.
(C) Date
Displays the current system date and time.
(d) bc Basic Calculator
Opens a calculator where you can perform arithmetic, floating-point calculations, etc.
(e) passwd
Used to change the password of the user.
(f) uname
Shows system information.
(g) help
Displays shell built-in command help (works in Bash).
(h) man
Displays the manual (documentation) of a command.
ASSIGNMENT – 5
[Link] – Print text to terminal
Used to display text or variables on the screen
[Link] – Print working directory
Shows the current directory path
[Link] – Change directory
Switches to another directory.
[Link] – Make a new directory
Creates a new folder.
5. cp – Copy files or directories
Copies files from one location to another.
[Link] – Move or rename files
Moves files to another location or renames them.
[Link] – Remove empty directories
Deletes a folder if it is empty.
[Link] – Remove files or directories
Deletes files (and with -r can delete directories recursively).
ASSIGNMENT – 6
1. ls
Lists files and directories in the current directory.
2. tty
Displays the terminal file (device) you’re using.
3. tput clear
Clears the terminal screen (no visible output, same as clear).
4. cat
Displays contents of a file.
5. more
Views file contents page by page.
6. wc
Counts lines, words, characters in a file.
7. ps
Shows processes running for the current shell.
8. file
Shows the type of a file.
ASSIGNMENT – 7
Q1. Implement the following CPU scheduling algorithms:
[Link]/FCFS scheduling
[Link]-Preemptive SJF scheduling
[Link] (Preemptive SJF) scheduling
[Link]-preemptive Priority scheduling
[Link] Priority scheduling
[Link] Robin scheduling
Ans.
def print_result(name, procs, wt, tat, seq):
print(f"\n---- {name} ----")
print("PID\tAT\tBT\tPR\tWT\tTAT")
for i,p in enumerate(procs):
print(f"{p['pid']}\t{p['arrival']}\t{p['burst']}\t{p['priority']}\t{wt[i]}\t{tat[i]}")
print(f"Avg WT: {sum(wt)/len(wt):.2f}\tAvg TAT: {sum(tat)/len(tat):.2f}")
print("Gantt:", " | ".join(seq))
# FCFS
def fcfs(p):
[Link](key=lambda x:x['arrival'])
time,wt,tat,seq=0,[],[],[]
for i in p:
time=max(time,i['arrival']); [Link](time-i['arrival'])
[Link](i['pid']); time+=i['burst']
[Link](time-i['arrival'])
print_result("FCFS",p,wt,tat,seq)
# SJF Non Preemptive
def sjf(p):
n=len(p);done=[0]*n;time,seq=0,[];wt,tat=[0]*n,[0]*n
while sum(done)<n:
idx=-1;bt=9999
for i in range(n):
if p[i]['arrival']<=time and not done[i] and p[i]['burst']<bt:
idx=i;bt=p[i]['burst']
if idx==-1: time+=1;continue
[Link](p[idx]['pid']); time+=p[idx]['burst']; done[idx]=1
tat[idx]=time-p[idx]['arrival']; wt[idx]=tat[idx]-p[idx]['burst']
print_result("SJF",p,wt,tat,seq)
# SRTF
def srtf(p):
n=len(p);rem=[x['burst'] for x in p];done=0;time=0;wt,tat=[0]*n,[0]*n;seq=[]
while done<n:
idx=-1;bt=9999
for i in range(n):
if p[i]['arrival']<=time and rem[i]>0 and rem[i]<bt:
idx=i;bt=rem[i]
if idx==-1: time+=1;continue
[Link](p[idx]['pid']); rem[idx]-=1; time+=1
if rem[idx]==0:
done+=1;tat[idx]=time-p[idx]['arrival']; wt[idx]=tat[idx]-p[idx]['burst']
print_result("SRTF",p,wt,tat,seq)
# Priority Non Preemptive
def priority_np(p):
n=len(p);done=[0]*n;time=0;wt,tat=[0]*n,[0]*n;seq=[]
while sum(done)<n:
idx=-1;pr=9999
for i in range(n):
if p[i]['arrival']<=time and not done[i] and p[i]['priority']<pr:
idx=i;pr=p[i]['priority']
if idx==-1: time+=1;continue
[Link](p[idx]['pid']); time+=p[idx]['burst']; done[idx]=1
tat[idx]=time-p[idx]['arrival']; wt[idx]=tat[idx]-p[idx]['burst']
print_result("Priority NP",p,wt,tat,seq)
# Priority Preemptive
def priority_p(p):
n=len(p);rem=[x['burst'] for x in p];done=0;time=0;wt,tat=[0]*n,[0]*n;seq=[]
while done<n:
idx=-1;pr=9999
for i in range(n):
if p[i]['arrival']<=time and rem[i]>0 and p[i]['priority']<pr:
idx=i;pr=p[i]['priority']
if idx==-1: time+=1;continue
[Link](p[idx]['pid']); rem[idx]-=1; time+=1
if rem[idx]==0:
done+=1;tat[idx]=time-p[idx]['arrival']; wt[idx]=tat[idx]-p[idx]['burst']
print_result("Priority P",p,wt,tat,seq)
# Round Robin
def rr(p,q):
n=len(p);rem=[x['burst'] for x in p];wt,tat=[0]*n,[0]*n;seq=[]
time=0;ready=[];visited=[False]*n;[Link](key=lambda
x:x['arrival']);[Link](0);visited[0]=True
while ready:
i=[Link](0);[Link](p[i]['pid'])
if rem[i]>q: time+=q;rem[i]-=q
else: time+=rem[i];rem[i]=0;tat[i]=time-p[i]['arrival'];wt[i]=tat[i]-p[i]['burst']
for j in range(n):
if p[j]['arrival']<=time and not visited[j] and rem[j]>0:
[Link](j);visited[j]=True
if rem[i]>0: [Link](i)
if not ready:
for j in range(n):
if rem[j]>0: [Link](j);visited[j]=True;break
print_result("Round Robin",p,wt,tat,seq)
# MAIN FUNCTION
if __name__=="__main__":
n=int(input("No. of Processes: "))
p=[]
for i in range(n):
pid=f"P{i+1}"
at=int(input(f"AT of {pid}: "))
bt=int(input(f"BT of {pid}: "))
pr=int(input(f"Priority of {pid}: "))
[Link]({'pid':pid,'arrival':at,'burst':bt,'priority':pr})
q=int(input("Time Quantum: "))
fcfs([Link]()); sjf([Link]()); srtf([Link]())
priority_np([Link]()); priority_p([Link]()); rr([Link](),q)
OUTPUT :
Q2. Implement the following page replacement algorithms:
1. FIFO/FCFS
2. Optimal
3. LRU
Ans.
def fifo(pages, frames):
memory, faults = [], 0
for p in pages:
if p not in memory:
faults += 1
if len(memory) < frames:
[Link](p)
else:
[Link](0)
[Link](p)
return faults
def optimal(pages, frames):
memory, faults = [], 0
for i in range(len(pages)):
p = pages[i]
if p not in memory:
faults += 1
if len(memory) < frames:
[Link](p)
else:
future = pages[i+1:]
replace_index = -1
farthest_use = -1
for m in memory:
if m in future:
dist = [Link](m)
if dist > farthest_use:
farthest_use = dist
replace_index = [Link](m)
else:
replace_index = [Link](m)
break
memory[replace_index] = p
return faults
def lru(pages, frames):
memory, faults = [], 0
recent = {}
for i, p in enumerate(pages):
if p not in memory:
faults += 1
if len(memory) < frames:
[Link](p)
else:
# pick LRU page *that is still in memory*
lru_page = min(
(m for m in memory), key=lambda x: [Link](x, -1)
)
memory[[Link](lru_page)] = p
recent[p] = i
return faults
# MAIN
if __name__ == "__main__":
frames = int(input("Enter number of frames: "))
ref_input = input("Enter reference string (space or comma separated): ")
ref_input = ref_input.replace(",", " ").replace("\t", " ").strip()
pages = [int(x) for x in ref_input.split() if [Link]()]
print("\nPage Replacement Results:")
print(f"FIFO Page Faults: {fifo(pages, frames)}")
print(f"Optimal Page Faults: {optimal(pages, frames)}")
print(f"LRU Page Faults: {lru(pages, frames)}")
OUTPUT :