Os Ansh
Os Ansh
Ansh Kasaudhan
(2203491550011)
2023-2024
—
BCS-451
—
Under the Guidance of
Mr. Deepak Singh Sir
2
INTRODUCTION
PAGE 2
3
Index
S. Name of Date of Date of Page Teacher’s
No Program Conduction checking No. Sign
1. (i) To understand OS functionalities like
system configuration, device manager,
and group policy.
(ii) Understand the minimum
requirements of different Operating
System like Window XP, Window 8.1
and higher, Linux, Unix, Mac OS.
2. Basics of UNIX/ DOS Commands.
3. Implementation of CPU Scheduling.
(i) FCFS, (ii) SJF
4. Implementation of CPU Scheduling.
( i ) Shortest Remaining Time First
(ii) Priority based
5. Implementation of CPU Scheduling:
(i) Round Robin (ii) Longest Job First.
6. Implementation of Process and thread
(Life cycle of process): (i) Process
creation and Termination; (ii) Thread
creation and Termination
7. Producer-Consumer Problem using
Semaphores and Reader Writer Problem
8. Simulate algorithm for deadlock
prevention and detection
9. Simulate the algorithm for deadlock
avoidance and study about deadlock
recovery.
10. Simulate memory allocation methods:
(i) Best Fit, (ii) Worst Fit and (iii)
Next Fit
11. Simulate page replacement algorithms:
FIFO, LRU and Optimal.
12. Implementation of Disk Scheduling
using FCFS, SCAN and C-SCAN
algorithm
13. Implementation of Disk Scheduling
using LOOK, C-LOOK and SSTF
algorithm
4
Program 1
Aim: - (i) To understand OS functionalities like system configuration, device manager, and
group policy.
Theory: -
MSconfig
• Open Search in the Toolbar and type Run, or select Run from your Start Menu.
• Type ‘msconfig’ in the Run command and click OK.
General Tab
1. Normal Startup:
• Loads all device drivers and services.
2. Diagnostic Startup:
• Loads basic devices and services only, similar to Safe Mode.
3. Selective Startup:
• Allows the user to select which programs and services to load.
Boot Tab 5
1. Boot Options:
• Safe Boot: Boots Windows in Safe Mode with different sub-options:
o Minimal: Basic Safe Mode.
o Alternate Shell: Safe Mode with Command Prompt.
o Active Directory Repair: Used to repair the Active Directory server.
o Network: Safe Mode with networking.
• No GUI Boot: Boots without the Windows GUI (graphical user interface).
• Boot Log: Creates a file of the boot process.
• Base Video: Boots using basic video drivers.
• OS Boot Information: Displays drivers being loaded during boot.
• Timeout: Specifies the time to display the list of operating systems.
2. Advanced Options:
• Number of processors: Limits the number of processors to use.
• Maximum memory: Limits the amount of memory used.
• Debugging mode: Enables debugging.
Tools Tab
• Provides quick access to various system tools and utilities, such as:
• System Information
• Event Viewer
• Performance Monitor
• Command Prompt
• Registry Editor
• Task Manager
These features of msconfig make it a powerful utility for managing the boot process and troubleshooting
startup issues in Windows.
Gpedit.msc
The Group Policy Editor is a Windows administration tool that allows users to configure many important
settings on their computers or networks. Administrators can configure password requirements, startup
programs, and define what applications or settings users can change.
6
Steps to open Group policy editor
Option 1: Open Local Group Policy Editor in Run
• Open Search in the Toolbar and type Run, or select Run from your Start Menu.
• Type ‘gpedit.msc’ in the Run command and click OK.
Option 5: Open Local Group Policy Editor in Start Menu Control Panel
There are hundreds of different settings like this in Group Policy Editor.
• Computer Configuration: These policies apply to the local computer, and do not change per user.
• User Configuration: These policies apply to users on the local machine, and will apply to any new
users in the future, on this local computer.
• Those two main categories are further broken down into sub-categories:
• Software Settings: Software settings contain software specific group policies: this setting is empty by
default.
7
Regedit
The Windows Registry Editor (regedit) is a graphical tool in the Microsoft Windows operating system (OS)
that enables authorized users to view the Windows registry and make changes.
The Windows registry, also known as the registry, is a hierarchical database that stores the configuration
settings required for a computer to operate efficiently. This information includes basic boot-up functions, user
profile information, startup options, installed applications and drivers, system hardware information and
specific design settings.
• Open Search in the Toolbar and type Run, or select Run from your Start Menu.
• Type ‘regedit’ in the Run command and click OK.
• Hierarchical Structure: The registry is organized in a tree-like structure with keys and subkeys,
similar to folders and files in a filesystem. The main root keys include:
o HKEY_CLASSES_ROOT (HKCR): Contains information about registered applications,
file associations, and COM objects.
o HKEY_CURRENT_USER (HKCU): Stores settings specific to the current user.
o HKEY_LOCAL_MACHINE (HKLM): Contains settings that apply to the local
machine, regardless of the user.
o HKEY_USERS (HKU): Contains user-specific settings for all users on the system.
o
o HKEY_CURRENT_CONFIG (HKCC): Contains hardware profile information used
8 at
system startup.
• Keys: Like folders in the file system, they can contain subkeys and values.
• Values: Come in several types, including:
o String (REG_SZ): A fixed-length text string.
o Binary (REG_BINARY): Raw binary data.
o DWORD (REG_DWORD): A 32-bit number.
o QWORD (REG_QWORD): A 64-bit number.
o Multi-String (REG_MULTI_SZ): An array of strings.
o Expandable String (REG_EXPAND_SZ): A string that contains environment variables.
• Users can add, modify, delete, and rename keys and values.
• Find: Allows users to search for specific keys, values, or data within the registry.
• Find Next: Continues the search from the current location.
• Export: Allows users to save a part or the entirety of the registry to a file, which can be used for
backup purposes or for transferring settings to another machine.
• Import: Enables users to load a previously exported registry file, merging its contents with the
current registry.
5. Permissions:
• Users can set permissions on keys to control access, allowing or denying specific users or groups
the ability to read or modify certain keys.
6. Favorites:
• Users can add frequently accessed keys to a favorites list for quick access.
7. View Options:
• Split View: Users can split the view to see different parts of the registry simultaneously.
• Status Bar: Shows the path of the selected key and the number of subkeys and values it contains.
9
Aim: - (ii) Understand the minimum requirements of different Operating System like
Window XP, Window 8.1 and higher, Linux, Unix, Mac OS.
Theory: -This section aims to outline and compare the minimum hardware and software
requirements for various popular operating systems, including Windows XP, Windows 8.1
and higher, Linux, Unix, and Mac OS. Understanding these requirements is crucial for
system compatibility and optimal performance.
Processor (CPU): The central processing unit's speed and capabilities, measured in gigahertz
(GHz), affect the system's ability to execute tasks. Different OS versions have varying minimum CPU
requirements to ensure smooth operation.
Memory (RAM): Random-access memory is critical for multitasking and running applications.
Higher RAM allows for better performance and handling of more demanding software.
Storage (Hard Drive/SSD): The amount of available storage space is necessary for the OS
installation and for storing applications and files. Solid-state drives (SSDs) offer faster data access
speeds compared to traditional hard drives (HDDs).
Graphics Card: A dedicated or integrated graphics processing unit (GPU) is essential for
rendering images, videos, and graphical interfaces. Some OS require specific graphics capabilities to
support advanced features.
Other Peripherals: Input and output devices like keyboards, mice, monitors, and printers may
have specific requirements based on the OS.
OS Kernel: The core component of the operating system that manages hardware resources and
facilitates interactions between hardware and software.
Drivers: Software that allows the OS to communicate with hardware devices such as printers,
graphics cards, and network adapters.
Utilities: Essential tools and programs that come with the OS to perform system maintenance
and management tasks.
Libraries: Pre-compiled code modules that applications can use to perform common functions
without having to write code from scratch. These are often required for running certain applications.
Compatibility: Specific software versions or features that must be present for the OS to function
correctly with other installed applications.
Security Software: Built-in or additional antivirus and firewall programs to protect the system
from malware and unauthorized access.
Program 2
Aim: - Basics of UNIX/ DOS Commands.
Theory: -
MS Dos Commands
MS-DOS is a text-based system of Microsoft Operating System; The users interact with the
computer by typing text-based commands rather than a Graphical User Interface. These
commands allow users to perform various tasks, such as copying, deleting, or moving files,
and managing programs.
File Management: MS Dos commands enable users to navigate through directories and
create, delete, or copy files, enabling efficient file management.
System Configuration: Users can configure system settings, manage drives, and analyze
hardware issues using MS Dos commands, providing a robust toolkit for system
customization.
Program Execution: MS Dos for commands facilitate the execution of programs and scripts,
offering a streamlined approach to launching applications without the need for graphical
interfaces.
1. Select the Start Menu (the Windows icon) in the taskbar, or press the Windows key.
2. Type cmd.
3. Select Command Prompt from the list.
If you're using the latest version of Windows 11, Command Prompt will open
within Terminal.
13
Program 3
Aim - Implementation of CPU Scheduling. (i) FCFS, (ii) SJF
Theory: -
FCFS Algorithm
Algorithm: -
1. Initialize Variables: Declare arrays for process IDs, burst times, arrival times, completion times, turn-
around times, and waiting times. Initialize variables for total waiting time and total turn-around time.
2. Input Number of Processes: Ask the user for the number of processes (n) and store the input.
3. Input Burst Time and Arrival Time: For each process, prompt the user to input the burst time and
arrival time.
4. Calculate CT, TAT, WT:
• Set current_time to 0.
• For each process:
o If current_time is less than the arrival time, set it to the arrival time.
o Calculate completion time (ct[i]) as current_time + bt[i].
o Update current_time to ct[i].
o Calculate turn-around time (tat[i]) as ct[i] - at[i].
o Calculate waiting time (wt[i]) as tat[i] - bt[i].
5. Display Process Details: Print the process ID, burst time, arrival time, completion time, turn-around
time, and waiting time for each process.
6. Calculate and Display Averages: Calculate average waiting time (avg_wt) and average turn-around
time (avg_tat). Print these averages.
Code: -
#include <stdio.h>
// Function to find the completion time, turn around time and waiting time for all
processes
void findCT_TAT_WT(int processes[], int n, int bt[], int at[], int ct[], int tat[], int wt[]) {
int current_time = 0;
// Function to find completion time, turn around time and waiting time for all processes
findCT_TAT_WT(processes, n, bt, at, ct, tat, wt);
SJF Algorithm
DESCRIPTION: -The job which has shortest burst time is executed first.
Algorithm: -
1) Initialize Variables: Declare arrays for process IDs, burst times, arrival times, completion times, turn-
around times, and waiting times. Initialize variables for total waiting time and total turn-around time.
2) Input Number of Processes: Ask the user for the number of processes (n) and store the input.
3) Input Burst Time and Arrival Time: For each process, prompt the user to input the burst time.
4) Sort Processes by Burst Time: Sort the processes based on their burst times in ascending order.
5) Calculate CT, TAT, WT:
• Set current_time to 0.
• For each process in sorted order:
o Calculate completion time (ct[i]) as current_time + bt[i].
o Update current_time to ct[i].
o Calculate turn-around time (tat[i]) as ct[i] - at[i].
o Calculate waiting time (wt[i]) as tat[i] - bt[i].
6) Display Process Details: Print the process ID, burst time, arrival time, completion time, turn-around time,
and waiting time for each process.
7) Calculate and Display Averages: Calculate average waiting time (avg_wt) and average turn-around time
(avg_tat). Print these averages.
16
Code: -
#include <stdio.h>
// Function to find completion time, turn around time and waiting time for all processes
void findCT_TAT_WT(int processes[], int n, int bt[], int at[], int ct[], int tat[], int wt[]) {
int current_time = 0;
// Find completion time, turn around time and waiting time for all processes
findCT_TAT_WT(processes, n, bt, at, ct, tat, wt);
// Driver code
int main() {
int n;
int processes[n];
int burst_time[n];
int arrival_time[n];
Output: -
19
Program 4
Aim: - Implementation of CPU Scheduling. (i) Shortest Remaining Time First
(ii) Priority based
Theory: -
SRTF Algorithm
DESCRIPTION: -The process that have shortest remaining time is executed first.
Algorithm: -
1. Initialize Variables:
• Declare arrays for process IDs, burst times, arrival times, completion times, turn-around times,
and waiting times.
• Initialize remaining time for each process, current time, and completed process count.
2. Input Number of Processes:
• Prompt user for number of processes (n) and store it.
3. Input Burst Time and Arrival Time for Each Process:
• For each process, get burst time and arrival time from user.
4. Find Shortest Remaining Job:
• Create a function to find the process with shortest remaining time among arrived and
uncompleted processes.
5. Calculate Completion Time, Turn-Around Time, and Waiting Time:
• Loop until all processes are completed:
• Find process with shortest remaining time.
• If process found:
o Reduce its remaining time by 1.
o Update current time.
o If remaining time becomes 0, calculate completion time, turn-around time, and waiting
time.
6. Display Process Details:
• Print process ID, burst time, arrival time, completion time, turn-around time, and waiting time
for each process.
7. Calculate and Display Averages:
• Calculate average waiting time and average turn-around time.
• Print these averages.
Code: -
#include <stdio.h>
#include <limits.h>
return shortestIndex;
}
// Function to find completion time, turn-around time and waiting time for all processes
void findCT_TAT_WT(int processes[], int n, int bt[], int at[], int ct[], int tat[], int wt[]) {
int rt[n];
int currentTime = 0;
int completed = 0;
while (completed != n) {
int shortestJobIndex = findShortestJob(bt, at, rt, n, currentTime);
if (shortestJobIndex == -1) {
currentTime++;
continue;
}
// If a process is completed
if (rt[shortestJobIndex] == 0) {
completed++;
// Driver code
int main() {
int n;
int processes[n];
int burst_time[n];
int arrival_time[n];
Priority Algorithm
DESCRIPTION: - The process which ha highest priority (lowest number or vice versa) is
executed first.
Algorithm: -
1. Initialize Variables:
• Declare arrays for process IDs, burst times, arrival times, priorities, completion times, turn-
around times, and waiting times.
2. Input Number of Processes:
• Prompt the user for the number of processes (n) and store the input.
3. Input Process Details:
• For each process:
o Prompt the user to input burst time, arrival time, and priority.
4. Sort Processes by Priority:
• Sort the processes based on their priorities in ascending order.
5. Calculate Completion Time, Turn-Around Time, and Waiting Time:
• Initialize current time to 0.
• Loop through the sorted processes:
o Calculate completion time, turn-around time, and waiting time for each process.
6. Display Process Details:
• Print process ID, burst time, arrival time, priority, completion time, turn-around time, and
waiting time for each process.
7. Calculate and Display Averages:
• Calculate average waiting time and average turn-around time.
• Print these averages.
Code: - 23
#include <stdio.h>
#include <stdbool.h>
temp = bt[j];
bt[j] = bt[j + 1];
bt[j + 1] = temp;
temp = at[j];
at[j] = at[j + 1];
at[j + 1] = temp;
temp = priority[j];
priority[j] = priority[j + 1];
priority[j + 1] = temp;
}
}
}
}
// Function to find completion time, turn-around time, and waiting time for all processes
void findCT_TAT_WT(int processes[], int n, int bt[], int at[], int priority[], int ct[], int tat[], int wt[]) {
int currentTime = 0;
// Driver code
int main() {
int n;
int processes[n];
int burst_time[n];
int arrival_time[n];
int priority[n];
// Input burst time, arrival time, and priority for each process
for (int i = 0; i < n; i++) {
processes[i] = i + 1; // Process IDs
printf("Enter burst time for process %d: ", i + 1);
scanf("%d", &burst_time[i]);
printf("Enter arrival time for process %d: ", i + 1);
scanf("%d", &arrival_time[i]);
printf("Enter priority for process %d: ", i + 1);
scanf("%d", &priority[i]);
}
// Calculate average waiting time and average turn-around time 25
findavgTime(processes, n, burst_time, arrival_time, priority);
return 0;
}
Output: -