0% found this document useful (0 votes)
3 views13 pages

Os lab file

The document outlines the hardware and software requirements for various operating systems, including UNIX, Linux, Windows XP, and Windows 7/8. It also describes experiments involving UNIX system calls for process and file management, as well as simulations of CPU scheduling algorithms like FCFS and SJF. Each section includes code examples and outputs demonstrating the functionality of the respective operating systems and algorithms.

Uploaded by

anonymousforfun8
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)
3 views13 pages

Os lab file

The document outlines the hardware and software requirements for various operating systems, including UNIX, Linux, Windows XP, and Windows 7/8. It also describes experiments involving UNIX system calls for process and file management, as well as simulations of CPU scheduling algorithms like FCFS and SJF. Each section includes code examples and outputs demonstrating the functionality of the respective operating systems and algorithms.

Uploaded by

anonymousforfun8
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
You are on page 1/ 13

Experiment 1: Study of hardware and software requirements of different operating systems (UNIX,

LINUX, WINDOWS XP, WINDOWS 7/8).

Solution:
When studying the hardware and software requirements for different operating systems, it's
important to look at the minimum and recommended specifications for each one. Below is a general
overview of the hardware and software requirements for four popular operating systems: UNIX, Linux,
Windows XP, and Windows 7/8.

1. UNIX Operating System


Unix is a powerful, multi-user, multitasking operating system that can run on various hardware
platforms, from personal computers to large servers. While it is most often associated with
workstations or server systems, the requirements can vary greatly depending on the specific
distribution or version of UNIX (e.g., Solaris, AIX, HP-UX).

Hardware Requirements (for a general UNIX system):


Processor: At least a 32-bit processor (e.g., Intel/AMD compatible, or ARM-based systems). For
modern systems, a 64-bit processor is recommended.
RAM: Minimum of 256MB to 1GB of RAM. For more intensive usage, such as server environments,
4GB or more may be required.
Disk Space: Minimum of 1GB of free disk space. For servers or advanced use, 10GB or more might
be required.

Display: VGA monitor with a resolution of at least 800x600 pixels.


Other Requirements: Network interface card (for networking) and I/O peripherals (e.g., keyboard,
mouse).

Software Requirements:
System Libraries: Core libraries like libc (standard C library), X11 libraries for graphical interfaces,
etc.
Compilers: GCC (GNU Compiler Collection) or similar for compiling code.
Shell: Bash (Bourne Again Shell) or C Shell.
Utilities: A variety of tools for managing processes, files, and networking.
2. Linux Operating System
Linux is an open-source, Unix-like operating system kernel that supports a wide range of hardware
platforms. It comes in many distributions such as Ubuntu, Fedora, Debian, Red Hat, etc.

Hardware Requirements (for general Linux distributions like Ubuntu, Fedora):


Processor: Minimum 1GHz processor (32-bit or 64-bit), modern Intel or AMD processors are
commonly used.
RAM: Minimum of 512MB to 1GB for lightweight distributions. More complex distributions or those
running graphical interfaces may need 2GB or more.
Disk Space: Minimum 5GB to 20GB of disk space, depending on the distribution and whether
additional software is installed.
Display: VGA-compatible display, with a resolution of at least 800x600 for non-graphical
environments and 1024x768 for graphical interfaces.
Other Requirements: Network adapter for network connectivity, USB devices, and CD/DVD drive
for installation.

Software Requirements:

Kernel: A modern version of the Linux kernel (e.g., version 4.x or 5.x).
System Libraries: Standard libraries like glibc.
Shell: Bash or other shell alternatives.
Graphical User Interface (GUI): Optional, but X11, GNOME, or KDE for graphical environments
are common.
Package Manager: A package manager like apt (for Debian-based systems), yum (for Red Hat-based
systems), or zypper (for openSUSE).
Utilities: A full suite of command-line utilities like vi, curl, wget, etc.

3. Windows XP
Windows XP is an older operating system that was widely used from 2001 to the late 2000s. It has
been phased out and is no longer supported, but it is important for historical purposes.

Hardware Requirements:
Processor: 233 MHz or higher, ideally 500 MHz or more.
RAM: Minimum 64MB, recommended 128MB or more for smoother operation.
Disk Space: At least 1.5GB of free hard drive space.
Display: VGA or higher resolution, minimum of 800x600.
Other Requirements: Keyboard, mouse, CD-ROM drive (for installation).

Software Requirements:
System Libraries: Windows XP uses proprietary system libraries such as Kernel32.dll, User32.dll,
and GDI32.dll.
Windows Shell: Windows Explorer for GUI and command prompt for text-based operations.
Networking: TCP/IP stack for network support.

4. Windows 7/8
Windows 7 and 8 are much more modern operating systems with higher hardware requirements.
Windows 8 introduced a more touch-optimized interface and improvements in performance, while
Windows 7 was widely used for both home and enterprise environments.

Windows 7 (Minimum Requirements):


Processor: 1 GHz or faster processor (32-bit or 64-bit).
RAM: Minimum 1GB RAM (32-bit) or 2GB RAM (64-bit).

Disk Space: At least 16GB for 32-bit OS or 20GB for 64-bit OS.
Display: 800x600 resolution or higher.
Other Requirements: DVD-ROM drive, DirectX 9 graphics device with WDDM 1.0 or higher driver.
Windows 7 (Recommended Requirements):
Processor: 2 GHz or faster.

RAM: 4GB RAM or more.


Disk Space: 20GB or more.
Graphics: DirectX 10 or higher compatible graphics card.
Other Requirements: 32-bit or 64-bit compatible hardware.

Windows 8 (Minimum Requirements):


Processor: 1 GHz or faster, with support for PAE, NX, and SSE2.
RAM: 1GB for 32-bit, 2GB for 64-bit.

Disk Space: At least 16GB for 32-bit OS, 20GB for 64-bit OS.
Graphics: DirectX 9 graphics device with WDDM driver.
Display: 1024x768 resolution or higher.
Other Requirements: DVD-ROM drive, internet connection for updates and activation.
Windows 8 (Recommended Requirements):
Processor: 2 GHz or faster.
RAM: 4GB or more.
Disk Space: 20GB or more.
Graphics: DirectX 10 compatible graphics card.

Software Requirements:

System Libraries: System DLLs such as kernel32.dll, advapi32.dll, and user32.dll.


Windows Shell: Windows Explorer (Windows 7) or Start Screen (Windows 8).
Networking: TCP/IP stack, network adapter with Ethernet/Wi-Fi support.
Drivers: Support for a wide range of hardware components like printers, graphics cards, sound cards,
etc.
Experiment 2: Execute various UNIX system calls for
i. Process management
ii. File management

iii. Input/output System calls

Solution:

#include <stdio.h>

#include <stdlib.h>

#include <unistd.h>

#include <fcntl.h>

#include <sys/types.h>

#include <sys/wait.h>

// This program demonstrates:

// 1. Process management (fork, exec, wait)

// 2. File management (open, write, read, close)

// 3. I/O system calls (read, write)

int main() {

int fd;

char buffer[100];

pid_t pid;

// 1. File Management: create and write to a file

fd = open("example.txt", O_CREAT | O_WRONLY | O_TRUNC, 0644);

if (fd < 0) {

perror("Error creating file");

exit(1);

write(fd, "This is written by the parent process.\n", 40);

close(fd);

// 2. Process Management: create a child process

pid = fork();

if (pid < 0) {
perror("fork failed");

exit(1);

if (pid == 0) {

// Child Process

printf("Child: My PID is %d, reading from file...\n", getpid());

// File Management: read from the file

fd = open("example.txt", O_RDONLY);

if (fd < 0) {

perror("Child: Error opening file");

exit(1);

int n = read(fd, buffer, sizeof(buffer));

write(1, "Child: File contents:\n", 23); // Output to STDOUT

write(1, buffer, n);

close(fd);

// I/O System Call: exec to list files

printf("Child: Now executing 'ls -l'\n");

execlp("ls", "ls", "-l", NULL);

// If execlp fails

perror("exec failed");

exit(1);

} else {

// Parent Process

wait(NULL); // Wait for child to finish

printf("Parent: Child has finished execution.\n");

return 0;

}
Output:

Child: My PID is 12345, reading from file...

Child: File contents:

This is written by the parent process.

Child: Now executing 'ls -l'

(total directory listing from `ls -l` here...)

<output of `ls -l`, e.g.>:

-rw-r--r-- 1 user user 40 Apr 23 16:00 example.txt

-rwxr-xr-x 1 user user 8792 Apr 23 16:00 a.out

... (other files in the directory)

Parent: Child has finished execution.

This is written by the parent process.


Experiment 3: Simulate the FCFS CPU scheduling algorithm.

Solution:

#include<stdio.h>

struct process{

int id, at, bt, ct, tat, wt;

}p[100];

void sort_by_arrival(struct process[], int);

void display(struct process[], int);

int main()

float tat_sum=0, wt_sum=0, avg_tat=0, avg_wt=0;

int i, n;

printf("Enter number of processes: ");

scanf("%d", &n);

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

printf("Enter Process ID, Arrival Time and Burst Time of process %d: ",i);

scanf("%d %d %d",&p[i].id, &p[i].at, &p[i].bt);

sort_by_arrival(p, n);

//printf("\nProcesses after sorting:");

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

if(i==0) {

p[0].ct=p[0].at+p[0].bt;

else {

p[i].ct=p[i-1].ct+p[i].bt;

}
p[i].tat=p[i].ct-p[i].at;

p[i].wt=p[i].tat-p[i].bt;

//printf("\nProcess ID, Arrival Time and Burst Time of process %d: ",i);

//printf("%d %d %d",p[i].id, p[i].at, p[i].bt);

display(p, n);

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

tat_sum=tat_sum+p[i].tat;

wt_sum=wt_sum+p[i].wt;

avg_tat=tat_sum/n;

avg_wt=wt_sum/n;

printf("Average TAT= %f", avg_tat);

printf("Average WT= %f",avg_wt);

return 0;

void sort_by_arrival(struct process p[], int n) {

struct process temp;

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

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

if (p[j].at > p[j+1].at) {

temp = p[j];

p[j] = p[j+1];

p[j+1] = temp;

}
void display(struct process p[], int n)

int i;

printf("PID\tAT\tBT\tCT\tTAT\tWT");

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

printf("\n%d\t%d\t%d\t%d\t%d\t%d", p[i].id,p[i].at, p[i].bt, p[i].ct, p[i].tat, p[i].wt);

Output:

Enter number of processes: 4

Enter Process ID, Arrival Time and Burst Time of process 0: 1 0 5

Enter Process ID, Arrival Time and Burst Time of process 1: 2 1 4

Enter Process ID, Arrival Time and Burst Time of process 2: 3 2 2

Enter Process ID, Arrival Time and Burst Time of process 3: 4 3 1

PID AT BT CT TAT WT

1 0 5 5 5 0

2 1 4 9 8 4

3 2 2 11 9 7

4 3 1 12 9 8

Average TAT= 7.750000

Average WT= 4.750000


Experiment 4: Simulate the SJF CPU scheduling algorithm.

Solution:

#include <stdio.h>

struct Process {

int id, at, bt, ct, tat, wt, done;

};

int main() {

int n, time = 0, completed = 0;

struct Process p[20];

printf("Enter number of processes: ");

scanf("%d", &n);

// Input arrival and burst times

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

p[i].id = i + 1;

printf("Arrival time of P%d: ", p[i].id);

scanf("%d", &p[i].at);

printf("Burst time of P%d: ", p[i].id);

scanf("%d", &p[i].bt);

p[i].done = 0;

while(completed < n) {

int idx = -1;

int min_bt = 9999;

// Find shortest job available at current time

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

if(p[i].at <= time && p[i].done == 0 && p[i].bt < min_bt) {

min_bt = p[i].bt;
idx = i;

if(idx != -1) {

time += p[idx].bt;

p[idx].ct = time;

p[idx].tat = p[idx].ct - p[idx].at;

p[idx].wt = p[idx].tat - p[idx].bt;

p[idx].done = 1;

completed++;

} else {

time++; // wait for next process to arrive

// Output

float total_tat = 0, total_wt = 0;

printf("\nP\tAT\tBT\tCT\tTAT\tWT\n");

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

printf("P%d\t%d\t%d\t%d\t%d\t%d\n", p[i].id, p[i].at, p[i].bt, p[i].ct, p[i].tat, p[i].wt);

total_tat += p[i].tat;

total_wt += p[i].wt;

printf("\nAverage Turnaround Time = %.2f", total_tat / n);

printf("\nAverage Waiting Time = %.2f\n", total_wt / n);

return 0;

}
Output:

Enter number of processes: 4

Arrival time of P1: 0

Burst time of P1: 5

Arrival time of P2: 1

Burst time of P2: 4

Arrival time of P3: 2

Burst time of P3: 2

Arrival time of P4: 3

Burst time of P4: 1

P AT BT CT TAT WT

P1 0 5 5 5 0

P2 1 4 12 11 7

P3 2 2 8 6 4

P4 3 1 6 3 2

Average Turnaround Time = 6.25

Average Waiting Time = 3.25

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy