0% found this document useful (0 votes)
2 views9 pages

OS Practical

OS practical

Uploaded by

anwar.shadab1
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)
2 views9 pages

OS Practical

OS practical

Uploaded by

anwar.shadab1
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
You are on page 1/ 9

OS Practical

1. Study of hardware and software requirements of different operating systems (Unix,


Linux, Windows XP, Windows 7/8)

The study of hardware and software requirements of different operating systems involves
analyzing the minimum and recommended specifications needed for these systems to
function effectively. Here’s an overview of the hardware and software requirements for the
mentioned operating systems:

1. UNIX

 Hardware Requirements:
o Processor: Originally designed for PDP-11, now supports modern
architectures like x86, ARM, SPARC, etc.
o Memory (RAM): Varies depending on the distribution, but generally requires
4MB–16MB minimum for older UNIX systems.
o Storage: At least 100MB for basic installations; modern UNIX systems
require more for additional packages.
o Peripherals: Support for network interfaces, basic I/O devices.
 Software Requirements:
o Written in C, requiring a C compiler for development and updates.
o Requires shell environments (Bourne, Korn, or C shell).
o Utilities for file management, networking, and programming.

2. Linux

 Hardware Requirements (Example: Ubuntu or CentOS):


o Processor: x86, x86_64, ARM, or other architectures.
o Memory (RAM):
 Minimum: 512MB for server versions; 1GB for desktop versions.
 Recommended: 2GB or more for GUI-based distributions.
o Storage:
 Minimum: 10GB for installation.
 Recommended: 20GB or more for modern distributions.
o Peripherals: Support for a wide range of devices including printers, scanners,
and network interfaces.
 Software Requirements:
o GNU tools and utilities.
o Kernel version depending on the distribution.
o Package management tools like APT, YUM, or DNF.
o Desktop environments (optional): GNOME, KDE, XFCE, etc.
3. Windows XP

 Hardware Requirements:
o Processor: Pentium 233 MHz or faster (recommended: 300 MHz).
o Memory (RAM):
 Minimum: 64MB.
 Recommended: 128MB or more.
o Storage:
 Minimum: 1.5GB of free space.
 Recommended: 3GB or more for updates and software.
o Graphics: SVGA (800x600) or higher resolution.
o Peripherals: Support for USB, CD/DVD drives, and network adapters.
 Software Requirements:
o DirectX 8.1 or higher for multimedia applications.
o Internet Explorer 6 for web browsing (initial release).
o .NET Framework for certain applications.

4. Windows 7

 Hardware Requirements:
o Processor: 1 GHz or faster (32-bit or 64-bit).
o Memory (RAM):
 Minimum: 1GB (32-bit), 2GB (64-bit).
 Recommended: 4GB or more for advanced applications.
o Storage:
 Minimum: 16GB (32-bit), 20GB (64-bit).
o Graphics: DirectX 9-capable graphics card with WDDM 1.0 or higher driver.
o Peripherals: Support for USB, CD/DVD drives, and network interfaces.
 Software Requirements:
o DirectX 11 for multimedia and gaming.
o Internet Explorer 8 (default browser).
o Compatibility with most Windows XP applications through compatibility
mode.

5. Windows 8

 Hardware Requirements:
o Processor: 1 GHz or faster with PAE, NX, and SSE2 support.
o Memory (RAM):
 Minimum: 1GB (32-bit), 2GB (64-bit).
 Recommended: 4GB or more.
o Storage:
 Minimum: 16GB (32-bit), 20GB (64-bit).
o Graphics: Microsoft DirectX 9-capable with WDDM 1.0 driver.
o Peripherals: USB 2.0/3.0 support, DVD drive for installation media.
 Software Requirements:
o Windows Store for app installation.
o Internet Explorer 10 or later.
o Support for .NET Framework and legacy applications.

Key Takeaways:

 UNIX and Linux systems are versatile and can be adapted to a wide range of
hardware, making them suitable for embedded systems to high-performance servers.
 Windows XP has very modest requirements, reflecting its era, but is now outdated
and unsupported.
 Windows 7/8 introduced modern features, higher resource requirements, and better
multimedia support compared to XP.

Each operating system's requirements are tailored to the technology and use cases of its time,
with newer systems requiring more advanced hardware to handle improved functionality and
security features.

2. Implement CPU Scheduling Policies:


i. SJF
ii. Priority
iii. FCFS
iv. Multi-level Queue

Implementing CPU scheduling policies in C requires simulating how each policy allocates
CPU time to processes based on specific rules. Here is an explanation and implementation for
each policy.

1. Shortest Job First (SJF)

Explanation:

 Non-preemptive scheduling.
 The process with the shortest burst time is executed first.
 Minimizes average waiting time.

C Implementation:

#include <stdio.h>
void sjf(int n, int bt[], int p[]) {
int wt[n], tat[n], total_wt = 0, total_tat = 0;
int i, j, temp;

// Sort by burst time


for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
if (bt[i] > bt[j]) {
temp = bt[i]; bt[i] = bt[j]; bt[j] = temp;
temp = p[i]; p[i] = p[j]; p[j] = temp;
}
}
}

wt[0] = 0; // Waiting time for first process is 0


for (i = 1; i < n; i++) {
wt[i] = wt[i - 1] + bt[i - 1];
total_wt += wt[i];
}

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


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

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


for (i = 0; i < n; i++) {
printf("P%d\t%d\t\t%d\t\t%d\n", p[i], bt[i], wt[i], tat[i]);
}
printf("Average Waiting Time: %.2f\n", (float)total_wt / n);
printf("Average Turnaround Time: %.2f\n", (float)total_tat / n);
}

int main() {
int n = 4;
int bt[] = {6, 8, 7, 3};
int p[] = {1, 2, 3, 4};

printf("SJF Scheduling:\n");
sjf(n, bt, p);
return 0;
}

2. Priority Scheduling

Explanation:

 Non-preemptive scheduling.
 Process with the highest priority (lowest priority number) is executed first.
 If two processes have the same priority, scheduling may fall back to FCFS.

C Implementation:

#include <stdio.h>

void priorityScheduling(int n, int bt[], int p[], int pr[]) {


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

// Sort by priority
for (i = 0; i < n - 1; i++) {
for (j = i + 1; j < n; j++) {
if (pr[i] > pr[j]) {
temp = pr[i]; pr[i] = pr[j]; pr[j] = temp;
temp = bt[i]; bt[i] = bt[j]; bt[j] = temp;
temp = p[i]; p[i] = p[j]; p[j] = temp;
}
}
}

wt[0] = 0;
for (i = 1; i < n; i++) {
wt[i] = wt[i - 1] + bt[i - 1];
total_wt += wt[i];
}

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


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

printf("Process\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]);
}
printf("Average Waiting Time: %.2f\n", (float)total_wt / n);
printf("Average Turnaround Time: %.2f\n", (float)total_tat / n);
}

int main() {
int n = 4;
int bt[] = {10, 5, 8, 6};
int p[] = {1, 2, 3, 4};
int pr[] = {2, 1, 4, 3};
printf("Priority Scheduling:\n");
priorityScheduling(n, bt, p, pr);
return 0;
}

3. First-Come, First-Served (FCFS)

Explanation:

 Non-preemptive scheduling.
 Processes are executed in the order they arrive.
 Simple but can lead to high average waiting time due to the "convoy effect."

C Implementation:

#include <stdio.h>

void fcfs(int n, int bt[], int p[]) {


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

wt[0] = 0;
for (i = 1; i < n; i++) {
wt[i] = wt[i - 1] + bt[i - 1];
total_wt += wt[i];
}

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


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

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


for (i = 0; i < n; i++) {
printf("P%d\t%d\t\t%d\t\t%d\n", p[i], bt[i], wt[i], tat[i]);
}
printf("Average Waiting Time: %.2f\n", (float)total_wt / n);
printf("Average Turnaround Time: %.2f\n", (float)total_tat / n);
}

int main() {
int n = 4;
int bt[] = {8, 4, 2, 6};
int p[] = {1, 2, 3, 4};

printf("FCFS Scheduling:\n");
fcfs(n, bt, p);
return 0;
}

4. Multi-Level Queue Scheduling

Explanation:

 Processes are divided into different queues based on priority or type (e.g., system,
interactive, batch).
 Each queue can have its own scheduling algorithm.
 Scheduling between queues can use priority or round-robin.

C Implementation (Conceptual):

#include <stdio.h>

void multiLevelQueue() {
printf("Multi-Level Queue Scheduling simulation:\n");
printf("Queue 1: System processes (Round Robin)\n");
printf("Queue 2: Interactive processes (SJF)\n");
printf("Queue 3: Batch processes (FCFS)\n");
// Logic for simulating queues and switching between them would be more extensive.
}

int main() {
multiLevelQueue();
return 0;
}

Summary:

Each scheduling algorithm has specific advantages and use cases:

 SJF minimizes average waiting time.


 Priority Scheduling ensures high-priority tasks are executed first.
 FCFS is simple but can lead to high waiting times.
 Multi-Level Queue handles processes with varied priorities and requirements.

You might also like