0% found this document useful (0 votes)
13 views21 pages

OS Hardware & Software Requirements

The document outlines the hardware and software requirements for various operating systems including UNIX, Linux, Windows XP, Windows 7, and Windows 8. It also includes implementations of CPU scheduling policies such as Shortest Job First (SJF), First-Come First-Serve (FCFS), Priority Scheduling, Round Robin, and Multi-level Queue. Each program provides a structured approach to scheduling processes and calculating average waiting and turnaround times.

Uploaded by

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

OS Hardware & Software Requirements

The document outlines the hardware and software requirements for various operating systems including UNIX, Linux, Windows XP, Windows 7, and Windows 8. It also includes implementations of CPU scheduling policies such as Shortest Job First (SJF), First-Come First-Serve (FCFS), Priority Scheduling, Round Robin, and Multi-level Queue. Each program provides a structured approach to scheduling processes and calculating average waiting and turnaround times.

Uploaded by

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

Khushi Joshi 2200911540061 CSDS-1 G2

PROGRAM NO 01
OBJECTIVE:- Study of hardware and software requirements of different operating systems
(UNIX,LINUX,WINDOWS XP,WINDOWS7/8).

UNIX

Hardware Requirements:
- Processor: Typically, UNIX systems can run on a wide range of processors, from early mainframes and
minicomputers to modern RISC and CISC architectures.
- Memory: UNIX systems have historically been designed to run on systems with as little as 4 MB of RAM, but
modern implementations usually require more.
- Storage: Varies widely; early UNIX systems could run on 20 MB of disk space, while modern implementations need
significantly more.
- Network: Basic networking capabilities are often built-in, with support for various network interfaces.
Software Requirements:
- Kernel: UNIX kernel, which manages system resources.
- Shell: A command-line interface, like Bourne shell (sh), C shell (csh), or Korn shell (ksh).
- Utilities: Standard UNIX utilities for file management, text processing, and programming.

Linux

Hardware Requirements:
- Processor: Intel x86 or compatible, ARM, PowerPC, and more. Modern distributions support 64-bit processors.
- Memory: Minimum of 512 MB to 1 GB of RAM for lightweight distributions; 2 GB or more for standard desktop
distributions.
- Storage: Minimum of 5 GB for a basic installation; 20 GB or more for a full-featured desktop environment.
- Graphics: VGA capable; modern distributions may require 3D acceleration for advanced desktop effects.
Software Requirements:
- Kernel: Linux kernel, the core of the operating system.
- Shell: Bash (Bourne Again Shell) or other shells like Zsh, Fish.
- Desktop Environment: GNOME, KDE, XFCE, or others for graphical user interfaces.
- Package Manager: APT (Debian-based), YUM/DNF (Red Hat-based), or Pacman (Arch-based).

Windows XP

Hardware Requirements:
- Processor: Pentium 233 MHz or higher; recommended 300 MHz or higher.
- Memory: Minimum of 64 MB of RAM; recommended 128 MB or more.
- Storage: Minimum of 1.5 GB of available hard disk space.
- Graphics: Super VGA (800 x 600) or higher-resolution video adapter and monitor.
Software Requirements:
- Operating System: Windows XP installation media.
Khushi Joshi 2200911540061 CSDS-1 G2
- Applications: Various third-party applications available; legacy support for older software.
- Drivers: Specific drivers for hardware components (graphics, network, sound, etc.).

Windows 7

Hardware Requirements:
- Processor: 1 GHz or faster 32-bit (x86) or 64-bit (x64) processor.
- Memory: 1 GB RAM (32-bit) or 2 GB RAM (64-bit).
- Storage: 16 GB available hard disk space (32-bit) or 20 GB (64-bit).
- Graphics: DirectX 9 graphics device with WDDM 1.0 or higher driver.
Software Requirements:
- Operating System: Windows 7 installation media.
- Applications: Compatibility with a wide range of software, including legacy Windows XP applications in XP Mode
(Professional, Ultimate, and Enterprise editions).
- Drivers: Specific drivers for hardware components; improved plug-and-play support.

Windows 8

Hardware Requirements:
- Processor: 1 GHz or faster processor with PAE, NX, and SSE2 support.
- Memory: 1 GB RAM (32-bit) or 2 GB RAM (64-bit).
- Storage: 16 GB available hard disk space (32-bit) or 20 GB (64-bit).
- Graphics: Microsoft DirectX 9 graphics device with WDDM driver.
Software Requirements:
- Operating System: Windows 8 installation media.
- Applications: Support for modern UI (formerly Metro) apps and traditional desktop applications.
- Drivers: Specific drivers for hardware components; enhanced touch and gesture support for touch-enabled
devices.
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 02
OBJECTIVE:- Implement CPU Scheduling Policies using SJF.
#include <stdio.h>
int main() {
int A[100][4];
int i, j, n, total = 0, index, temp;
float avg_wt, avg_tat;
printf("Enter number of process: ");
scanf("%d", &n);
printf("Enter Burst Time:\n");
for (i = 0; i < n; i++) {
printf("P%d: ", i + 1);
scanf("%d", &A[i][1]);
A[i][0] = i + 1;
}
for (i = 0; i < n; i++) {
index = i;
for (j = i + 1; j < n; j++)
if (A[j][1] < A[index][1]) index = j;
temp = A[i][1];
A[i][1] = A[index][1];
A[index][1] = temp;

temp = A[i][0];
A[i][0] = A[index][0];
A[index][0] = temp;
}
A[0][2] = 0;
for (i = 1; i < n; i++) {
A[i][2] = 0;
for (j = 0; j < i; j++) A[i][2] += A[j][1];
total += A[i][2];
}
avg_wt = (float)total / n;
total = 0;
printf("P BT WT TAT\n");
for (i = 0; i < n; i++) {
A[i][3] = A[i][1] + A[i][2];
total += A[i][3];
printf("P%d %d %d %d\n", A[i][0], A[i][1], A[i][2], A[i][3]);
}
avg_tat = (float)total / n;
printf("Average Waiting Time= %f", avg_wt);
printf("\nAverage Turnaround Time= %f", avg_tat);
}
Khushi Joshi 2200911540061 CSDS-1 G2
Input:-

Output:-
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 03
OBJECTIVE:- Implement CPU Scheduling Policies using FCFS
#include <stdio.h>
int main() {
int n, bt[20], wt[20], tat[20], avwt = 0, avtat = 0, i, j;
printf("Enter total number of processes(maximum 20):");
scanf("%d", &n);
printf("\nEnter Process Burst Time\n");
for (i = 0; i < n; i++) {
printf("P[%d]:", i + 1);
scanf("%d", &bt[i]);
}
wt[0] = 0;
{
wt[i] = 0;
for (j = 0; j < i; j++) wt[i] += bt[j];
}
printf("\nProcess\t\tBurst Time\tWaiting Time\tTurnaround Time");

{
tat[i] = bt[i] + wt[i];
avwt += wt[i];
avtat += tat[i];
printf("\nP[%d]\t\t%d\t\t%d\t\t%d", i + 1, bt[i], wt[i], tat[i]);
}
avwt /= i;
avtat /= i;
printf("\n\nAverage Waiting Time:%d", avwt);
printf("\nAverage Turnaround Time:%d", avtat);
return 0;
Output:-
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 04
OBJECTIVE:- Implement CPU Scheduling Policies using PRIORITY
#include <stdio.h>
int main() {
int bt[20], p[20], wt[20], tat[20], pr[20], i, j, n, total = 0, pos, temp,
avg_wt, avg_tat;
printf("Enter Total Number of Processes: ");
scanf("%d", &n);
printf("\nEnter Burst Time and Priority for each process:\n");
for (i = 0; i < n; i++) {
printf("\nP [%d]\n", i + 1);
printf("Burst Time: ");
scanf("%d", &bt[i]);
printf("Priority: ");
scanf("%d", &pr[i]);
p[i] = i + 1;
}
for (i = 0; i < n; i++) {
pos = i;
for (j = i + 1; j < n; j++) {
if (pr[j] < pr[pos]) pos = j;
}
temp = pr[i];
pr[i] = pr[pos];
pr[pos] = temp;
temp = bt[i];
bt[i] = bt[pos];
bt[pos] = temp;
temp = p[i];
p[i] = p[pos];
p[pos] = temp;
}
wt[0] = 0;
for (i = 1; i < n; i++) {
wt[i] = 0;
for (j = 0; j < i; j++) wt[i] += bt[j];
total += wt[i];
}
for (i = 0; i < n; i++) tat[i] = bt[i] + wt[i];
avg_wt = total / n;
avg_tat = total / n;
printf("\nProcess\tBurst Time\tPriority\tWaiting Time\tTurnaround Time\n");
for (i = 0; i < n; i++) {
printf("P%d\t%d\t\t%d\t\t%d\t\t%d\n", p[i], bt[i], pr[i], wt[i], tat[i]);
}
Khushi Joshi 2200911540061 CSDS-1 G2
printf("\nAverage Waiting Time = %d\n", avg_wt);
printf("Average Turnaround Time = %d\n", avg_tat);
return 0;
}
Input:-

Output:-
Khushi Joshi 2200911540061 CSDS-1 G2

PROGRAM NO 05
OBJECTIVE:- Implement CPU Scheduling Policies using ROUND ROBIN
#include <conio.h>
#include <stdio.h>
void main() {
int i, NOP, sum = 0, count = 0, y, quant, wt = 0, tat = 0, at[10], bt[10],
temp[10];
float avg_wt, avg_tat;
printf(" Total number of process in the system: ");
scanf("%d", &NOP);
y = NOP;
for (i = 0; i < NOP; i++) {
printf("\n Enter the Arrival and Burst time of the Process[%d]\n", i + 1);
printf(" Arrival time is: \t");
scanf("%d", &at[i]);
printf(" \nBurst time is: \t");
scanf("%d", &bt[i]);
temp[i] = bt[i];
}
printf("Enter the Time Quantum for the process: \t");
scanf("%d", &quant);
printf("\n Process No \t\t Burst Time \t\t TAT \t\t Waiting Time ");
for (sum = 0, i = 0; y != 0;) {
if (temp[i] <= quant && temp[i] > 0) {
sum = sum + temp[i];
temp[i] = 0;
count = 1;
} else if (temp[i] > 0) {
temp[i] = temp[i] - quant;
sum = sum + quant;
}
if (temp[i] == 0 && count == 1) {
y--;
printf("\nProcess No[%d] \t\t %d\t\t\t\t %d\t\t\t %d", i + 1, bt[i],
sum - at[i], sum - at[i] - bt[i]);
wt = wt + sum - at[i] - bt[i];
tat = tat + sum - at[i];
count = 0;
}
if (i == NOP - 1) {
i = 0;
} else if (at[i + 1] <= sum) {
i++;
Khushi Joshi 2200911540061 CSDS-1 G2
} else {
i = 0;
}
}
avg_wt = wt * 1.0 / NOP;
avg_tat = tat * 1.0 / NOP;
printf("\n Average Turn Around Time: \t%f", avg_wt);
printf("\n Average Waiting Time: \t%f", avg_tat);
getch();
}
Output:-
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 06
OBJECTIVE:- WAP of Calculation of internal fragmentation .
#include <stdio.h>
#include <stdlib.h>
#define MEMORY_SEGMENT_SIZE 200
#define TOTAL_MEMORY_SIZE 1000
struct Process {
int id;
int size;
};
int total_allocated_memory = 0;
void allocate_memory(struct Process process) {
if (total_allocated_memory + [Link] <= TOTAL_MEMORY_SIZE &&
[Link] <= MEMORY_SEGMENT_SIZE) {
total_allocated_memory += [Link];
printf(
"Allocated %d MB of memory for process p%d. Total memory allocated: %d "
"MB\n",
[Link], [Link], total_allocated_memory);
} else {
printf("Not enough memory to allocate %d MB for process p%d\n",
[Link], [Link]);
}
}
int main() {
struct Process processes[] =
{{1, 180}, {2, 190}, {3, 200}, {4, 220},{5, 170}, {6, 300}, {7, 190}};
int num_processes = sizeof(processes) / sizeof(processes[0]);
for (int i = 0; i < num_processes; i++) {
allocate_memory(processes[i]);
}

return 0;
}
Output:-
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 07
OBJECTIVE:- Implement CPU Scheduling Policies using Multi-level Queue
# include <stdio.h>
struct process {
char name;
int AT, BT, WT, TAT, RT, CT;
} Q1[10], Q2[10], Q3[10];
int n;
void sortByArrival() {
struct process temp;
int i, j;
for (i = 0; i < n; i++) {
for (j = i + 1; j < n; j++) {
if (Q1[i].AT > Q1[j].AT) {
temp = Q1[i];
Q1[i] = Q1[j];
Q1[j] = temp;
}
}
}
}

int main() {
int i, j, k = 0, r = 0, time = 0, tq1 = 5, tq2 = 8, flag = 0;
char c;
printf("Enter no of processes:");
scanf("%d", &n);
for (i = 0, c = 'A'; i < n; i++, c++) {
Q1[i].name = c;
printf("Enter the arrival time and burst time of process %c: ", Q1[i].name);
scanf("%d%d", &Q1[i].AT, &Q1[i].BT);
Q1[i].RT = Q1[i].BT;
}
sortByArrival();
time = Q1[0].AT;
printf("Process in first queue following RR with qt=5");
printf("\nProcess\t\tRT\t\tWT\t\tTAT\t\t");
for (i = 0; i < n; i++) {
if (Q1[i].RT <= tq1) {
time += Q1[i].RT;
Q1[i].RT = 0;
Q1[i].WT = time - Q1[i].AT - Q1[i].BT;
Q1[i].TAT = time - Q1[i].AT;
printf("\n%c\t\t%d\t\t%d\t\t%d", Q1[i].name, Q1[i].BT, Q1[i].WT,
Q1[i].TAT);
Khushi Joshi 2200911540061 CSDS-1 G2
} else {
Q2[k].WT = time;
time += tq1;
Q1[i].RT -= tq1;
Q2[k].BT = Q1[i].RT;
Q2[k].RT = Q2[k].BT;
Q2[k].name = Q1[i].name;
k = k + 1;
flag = 1;
}
}
if (flag == 1) {
printf("\nProcess in second queue following RR with qt=8");
printf("\nProcess\t\tRT\t\tWT\t\tTAT\t\t");
}
for (i = 0; i < k; i++) {
if (Q2[i].RT <= tq2) {
time += Q2[i].RT;
Q2[i].RT = 0;
Q2[i].WT = time - tq1 - Q2[i].BT;
Q2[i].TAT = time - Q2[i].AT;
printf("\n%c\t\t%d\t\t%d\t\t%d", Q2[i].name, Q2[i].BT, Q2[i].WT,
Q2[i].TAT);

} else {
Q3[r].AT = time;
time += tq2;
Q2[i].RT -= tq2;
Q3[r].BT = Q2[i].RT;
Q3[r].RT = Q3[r].BT;
Q3[r].name = Q2[i].name;
r = r + 1;
flag = 2;
}
}

{
if (flag == 2) printf("\nProcess in third queue following FCFS ");
}
for (i = 0; i < r; i++) {
if (i == 0)
Q3[i].CT = Q3[i].BT + time - tq1 - tq2;
else
Q3[i].CT = Q3[i - 1].CT + Q3[i].BT;
}

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


Khushi Joshi 2200911540061 CSDS-1 G2
Q3[i].TAT = Q3[i].CT;
Q3[i].WT = Q3[i].TAT - Q3[i].BT;
printf("\n%c\t\t%d\t\t%d\t\t%d\t\t", Q3[i].name, Q3[i].BT, Q3[i].WT,
Q3[i].TAT);
}
}
Output:-
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 08
OBJECTIVE:- Implementation of contiguous allocation techniques.
(a). Worst-Fit
#include <conio.h>
#include <stdio.h>
#define max 25
void main() {
int frag[max], b[max], f[max], i, j, nb, nf, temp;
static int bf[max], ff[max];
clrscr();
printf("Memory Management Scheme - First Fit");
printf("\nEnter the number of blocks:");
scanf("%d", &nb);
printf("Enter the number of files:");
scanf("%d", &nf);
printf("\nEnter the size of the blocks:-\n");
for (i = 1; i <= nb; i++) {
printf("Block %d:", i);
scanf("%d", &b[i]);
}
printf("Enter the size of the files :-\n");
for (i = 1; i <= nf; i++) {
printf("File %d:", i);
scanf("%d", &f[i]);
}
for (i = 1; i <= nf; i++) {
for (j = 1; j <= nb; j++) {
if (bf[j] != 1) {
temp = b[j] - f[i];
if (temp >= 0) {
ff[i] = j;
break;
}
}
}
frag[i] = temp;
bf[ff[i]] = 1;
}
printf("\nFile_no:\tFile_size :\tBlock_no:\tBlock_size:\tFragement");
for (i = 1; i <= nf; i++)
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d", i, f[i], ff[i], b[ff[i]], frag[i]);
getch();
}
Khushi Joshi 2200911540061 CSDS-1 G2
Output:-

(b). Best-Fit
#include <conio.h>
#include <stdio.h>
#define max 25
void main() {
int frag[max], b[max], f[max], i, j, nb, nf, temp, lowest = 10000;
static int bf[max], ff[max];
printf("Enter the number of blocks:");
scanf("%d", &nb);
printf("Enter the number of files:");
scanf("%d", &nf);
printf("\nEnter the size of the blocks:-\n");
for (i = 1; i <= nb; i++) {
printf("Block %d:", i);
scanf("%d", &b[i]);
}
printf("Enter the size of the files :-\n");
for (i = 1; i <= nf; i++) {
printf("File %d:", i);
scanf("%d", &f[i]);
}
for (i = 1; i <= nf; i++) {
for (j = 1; j <= nb; j++) {
if (bf[j] != 1) {
temp = b[j] - f[i];
if (temp >= 0)
if (lowest > temp) {
ff[i] = j;
Khushi Joshi 2200911540061 CSDS-1 G2

lowest = temp;
}
}
}
frag[i] = lowest;
bf[ff[i]] = 1;
lowest = 10000;
}
printf("\nFile No\tFile Size \tBlock No\tBlock Size\tFragment");
for (i = 1; i <= nf && ff[i] != 0; i++)
printf("\n%d\t\t%d\t\t%d\t\t%d\t\t%d", i, f[i], ff[i], b[ff[i]], frag[i]);
getch();
}

Output:-
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 9
OBJECTIVE:- Implementation of page replacement algorithm using
(a) FIFO
#include <stdio.h>
#define FRAME_SIZE 3
int frames[FRAME_SIZE];
int front = 0;
int rear = 0;
int pageFaults = 0;
void displayFrames() {
for (int i = 0; i < FRAME_SIZE; i++) {
printf("%d ", frames[i]);
}
printf("\n");
}
void insertPage(int page) {
int i;
for (i = 0; i < rear; i++) {
if (frames[i] == page) {
printf("Page %d already in frame.\n", page);
displayFrames();
return;}
}
if (rear < FRAME_SIZE) {
frames[rear++] = page;
} else {
for (i = 0; i < FRAME_SIZE - 1; i++) {
frames[i] = frames[i + 1];
}
frames[i] = page;
}
pageFaults++;
printf("Page %d inserted:\n", page);
displayFrames();
}
int main() {
int requests[] = {1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4};
int n = sizeof(requests) / sizeof(requests[0]);
for (int i = 0; i < n; i++) {
insertPage(requests[i]);
}
printf("Total page faults: %d\n", pageFaults);
return 0;
}

Output:-
Khushi Joshi 2200911540061 CSDS-1 G2

(b) LRU
#include <limits.h>
#include <stdio.h>
#define FRAME_SIZE 3
int frames[FRAME_SIZE];
int usage[FRAME_SIZE];
int pageFaults = 0;
int time = 0;
void displayFrames() {
for (int i = 0; i < FRAME_SIZE; i++) {
printf("%d ", frames[i]); }
printf("\n");
}
int findLRU() {
int minUsage = INT_MAX, lruIndex = 0;
for (int i = 0; i < FRAME_SIZE; i++) {
if (usage[i] < minUsage) {
minUsage = usage[i];
lruIndex = i;
}
}
return lruIndex;
}
void insertPage(int page) {
int i;
for (i = 0; i < FRAME_SIZE; i++) {
Khushi Joshi 2200911540061 CSDS-1 G2
if (frames[i] == page) {
printf("Page %d already in frame.\n", page);
usage[i] = ++time;
displayFrames();
return; }
}
int lruIndex = findLRU();
frames[lruIndex] = page;
usage[lruIndex] = ++time;
pageFaults++;
printf("Page %d inserted:\n", page);
displayFrames();
}
int main() {
for (int i = 0; i < FRAME_SIZE; i++) {
frames[i] = -1; //-1 to indicate empty slots
usage[i] = 0;}
int requests[] = {1, 2, 3, 4, 1, 2, 5, 1, 2, 3, 4};
int n = sizeof(requests) / sizeof(requests[0]);
for (int i = 0; i < n; i++) {
insertPage(requests[i]);
}
printf("Total page faults: %d\n", pageFaults);
return 0;
}
Output:-
Khushi Joshi 2200911540061 CSDS-1 G2
PROGRAM NO 10
OBJECTIVE:- Implement file storage allocation technique: Contiguous(using array)
#include <stdio.h>
struct filep {
int id;
int start;
int count;
};
typedef struct filep files;
int main() {
int disk[100];
int i, j, k;
for (i = 0; i < 100; i++) disk[i] = -1;
files f[3];
for (i = 0; i < 3; i++) {
f[i].id = i;
printf("enter the number of blocks for file : %d \n", i);
scanf("%d", &f[i].count);
}
int flag = 0;
for (i = 0; i < 3; i++) {
flag = 0;
for (j = 0; j < 100; j++) {
if (disk[j] == -1) {
for (k = j; k < j + f[i].count && disk[k] == -1; k++) {
flag++;
printf("\n flag for file %d : %d\n", i, flag);
}
if (flag == f[i].count) {
for (k = j; k < j + f[i].count; k++) {
f[i].start = j;
disk[k] = f[i].id;
}
j = j + f[i].count;
break;
} else {
j = j + flag;
flag = 0;
}
}
if (j == 99 && flag == 0) printf("\n disk is full \n");
}
}
printf("\n here is the disk allocation details \n");
for (i = 0; i < 100; i++) printf("%d ", disk[i]);
return 0;
Khushi Joshi 2200911540061 CSDS-1 G2
}
Output:-

You might also like