0% found this document useful (0 votes)
65 views

Operating System Practical: Name:-Ashish Bhandar ROLL NO: - 1518 Div: - A Class: - Fy Bscit

This document contains details of 9 programming assignments for an Operating Systems practical course. It includes the aims and code snippets for assignments on installing virtual machines and guest operating systems, using Windows/Linux commands, creating shell scripts, and simulating CPU scheduling algorithms like FCFS, SJF, and Round Robin. The assignments increase in complexity and cover key topics in operating systems including process scheduling, virtualization, command line usage, and scripting.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Operating System Practical: Name:-Ashish Bhandar ROLL NO: - 1518 Div: - A Class: - Fy Bscit

This document contains details of 9 programming assignments for an Operating Systems practical course. It includes the aims and code snippets for assignments on installing virtual machines and guest operating systems, using Windows/Linux commands, creating shell scripts, and simulating CPU scheduling algorithms like FCFS, SJF, and Round Robin. The assignments increase in complexity and cover key topics in operating systems including process scheduling, virtualization, command line usage, and scripting.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

CLASS:- FY BSCIT

DIV :- A

OPERATING SYSTEM PRACTICAL

NAME :- ASHISH BHANDAR


ROLL NO :- 1518
DIV:- A
CLASS:- FY BSCIT
CLASS:- FY BSCIT
DIV :- A

INDEX

PRACTICAL 1
 AIM:- Installation of virtual machine software like
vmware VirtualBox, vmware workstation to install guest
operating systems.
REQUIRED STEPS:
 Step 1-: First go to a web browser and type vmware
then click on vmware official site.

tep 2-: Then click on downloads and here you will find
open source click on it.
CLASS:- FY BSCIT
DIV :- A

 Step 3-: Here scroll down and you will see desktop &
End – User Computing under that click on VMware
Player.

 Step 4-: Click on vmware workstation 15.5.2 player for


windows 64-bit operating systems download button.

 Step 5-: Then it requires you to restart the computer


for that click on yes.

 Step 6-: After restarting go to file explorer then click


on vmware player.

 Step 7-: A window appear which says vmware


workstation player setup wizard . Click on next to
continue.
CLASS:- FY BSCIT
DIV :- A

 Step 8-: Click on next to continue .

 Step9-: Then we have to select the destination of our


installation after selecting click on next to continue.

 Step 10-: click on next to continue


CLASS:- FY BSCIT
DIV :- A

 Step 11-: Click on next to continue.

 Step 12-: For installation click on install.

 Step 13-: After installation click on finish.


CLASS:- FY BSCIT
DIV :- A

 Step 14-: Once again you have to restart the computer.

 Step 15-: Then click on start button and click on


vmware workstation 15 player.

 Step 16-: Select for non commercial use.


CLASS:- FY BSCIT
DIV :- A

 Step 17-: Click on finish.

 Step 18-: After clicking finish button vmware


workstation is successfully installed on your
computer.
CLASS:- FY BSCIT
DIV :- A

PRACTICAL 2

 AIM:- Installation of any one operating system


in virtual machine using iso file like windows,
linux .
 Step 1-: First start vmware workstation then click on
create a new virtual machine .
CLASS:- FY BSCIT
DIV :- A

 
 Step2-: Then click on I will install operating system
later. The virtual machine will be created with a blank
hard disk 

 Step 3-: Now we have to select a operating system. I


have selected Microsoft Windows. Then click on next. 
CLASS:- FY BSCIT
DIV :- A

 Step4-: Now we have to give a name to our virtual


machine and also we have select the location of our
file.

 Step5-: Now click on split virtual disk into multiple


files then click on next.
CLASS:- FY BSCIT
DIV :- A

 Step 6-: Now click on finish button to finish the


process.

 Step 8-: Our windows guest operating system has


been successfully installed.
CLASS:- FY BSCIT
DIV :- A

PRACTICAL 3
CLASS:- FY BSCIT
DIV :- A

 AIM :- Windows/DOS Commands –


CLASS:- FY BSCIT
DIV :- A

PRACTICAL 4

 AIM :- Linux commands on files and directories with


options–
CLASS:- FY BSCIT
DIV :- A

PRACTICAL 5

 AIM :- Linux commands on files and process –


CLASS:- FY BSCIT
DIV :- A

PRACTICAL 6

 AIM :- Creating and Executing Shell Scripts.(Sample


Programs)
CODE :
#!/bin/sh

echo "what is your name?"

read name

echo "How do you do, $name?"

read remark

echo "I am $remark too!"


CLASS:- FY BSCIT
DIV :- A

PRACTICAL 7

 AIM :- Write a C program to simulate the FCFS 


non-preemptive CPU scheduling algorithms.
CODE:-
#include <stdio.h>
// Function to find the waiting time for all processes
int waitingtime(int proc[], int n,
int burst_time[], int wait_time[]) {
// waiting time for first process is 0
wait_time[0] = 0;
// calculating waiting time
for (int i = 1; i < n ; i++ )
wait_time[i] = burst_time[i-1] + wait_time[i-1] ;
return 0;
}
// Function to calculate turn around time
int turnaroundtime( int proc[], int n,
int burst_time[], int wait_time[], int tat[]) {
// calculating turnaround time by adding
// burst_time[i] + wait_time[i]
int i;
for ( i = 0; i < n ; i++)
CLASS:- FY BSCIT
DIV :- A

tat[i] = burst_time[i] + wait_time[i];


return 0;
}
//Function to calculate average time
int avgtime( int proc[], int n, int burst_time[]) {
int wait_time[n], tat[n], total_wt = 0, total_tat = 0;
int i;
//Function to find waiting time of all processes
waitingtime(proc, n, burst_time, wait_time);
//Function to find turn around time for all processes
turnaroundtime(proc, n, burst_time, wait_time, tat);
//Display processes along with all details
printf("Processes Burst Waiting Turn around \n");
// Calculate total waiting time and total turn
// around time
for ( i=0; i<n; i++) {
total_wt = total_wt + wait_time[i];
total_tat = total_tat + tat[i];
printf(" %d\t %d\t\t %d \t%d\n", i+1, burst_time[i],
wait_time[i], tat[i]);
}
printf("Average waiting time = %f\n", (float)total_wt /
(float)n);
CLASS:- FY BSCIT
DIV :- A

printf("Average turn around time = %f\n", (float)total_tat /


(float)n);
return 0;
}
// main function
int main() {
//process id's
int proc[] = { 1, 2, 3};
int n = sizeof proc / sizeof proc[0];
//Burst time of all processes
int burst_time[] = {5, 8, 12};
avgtime(proc, n, burst_time);
return 0;
}
CLASS:- FY BSCIT
DIV :- A

PRACTICAL 8

 AIM:- Write a C program to simulate the SJF


CPU Scheduling Algorithm
CODE
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,n,t,p[20],bt[20],wt[20],tat[20];
float awt=0,atat=0;
printf("Enter the number of processes : ");
scanf("%d",&n);
printf("Enter process number : \n");
for(i=0;i<n;i++)
{
scanf("%d",&p[i]);

}
printf("Enter process burst time : \n");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
CLASS:- FY BSCIT
DIV :- A

}
for(i=0;i<n;i++)
{
for(j=0;j<n-i-1;j++)
{
if(bt[j]>bt[j+1])
{
t=bt[j];
bt[j]=bt[j+1];
bt[j+1]=t;
t=p[j];
p[j]=p[j+1];
p[j+1]=t;
}
}
}
printf("process\t Burst time\t Waiting time\t Turnaround time
\n");
for(i=0;i<n;i++)
{
wt[i]=0;
tat[i]=0;
for(j=0;j<i;j++)
{
CLASS:- FY BSCIT
DIV :- A

wt[i]=wt[i]+bt[j];
}
tat[j]=wt[i]+bt[i];
awt=awt+wt[i]; atat=atat+tat[i];
printf("%d\t\t%d\t\t%d\t\t%d\n",p[i],bt[i],wt[i],tat[i]);
}
awt=awt/n;
atat=atat/n;
printf("\n Average waiting time : %d",awt);
printf("\n Average turn around time : %d",atat);
}

OUTPUT :
CLASS:- FY BSCIT
DIV :- A

PRACTICAL 9

 AIM:- Write a C program to simulate the


ROUND ROBIN CPU Scheduling Algorithm
CODE
#include<stdio.h>
#include<conio.h>

void main()
{
// initlialize the variable name
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; // Assign the number of process to variable y

// Use for loop to enter the details of the process like Arrival
time and the Burst Time 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"); // Accept arrival time
CLASS:- FY BSCIT
DIV :- A

scanf("%d", &at[i]);
printf(" \nBurst time is: \t"); // Accept the Burst time
scanf("%d", &bt[i]);
temp[i] = bt[i]; // store the burst time in temp array
}
// Accept the Time qunat
printf("Enter the Time Quantum for the process: \t");
scanf("%d", &quant);
// Display the process No, burst time, Turn Around Time and the
waiting time
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) // define the conditions
{
sum = sum + temp[i];
temp[i] = 0;
count=1;
}
else if(temp[i] > 0)
{
temp[i] = temp[i] - quant;
sum = sum + quant;
}
CLASS:- FY BSCIT
DIV :- A

if(temp[i]==0 && count==1)


{
y--; //decrement the process no.
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++;
}
else
{
i=0;
}
}
// represents the average waiting time and Turn Around time
avg_wt = wt * 1.0/NOP;

avg_tat = tat * 1.0/NOP;


CLASS:- FY BSCIT
DIV :- A

printf("\n Average Turn Around Time: \t%f", avg_wt);


printf("\n Average Waiting Time: \t%f", avg_tat);
getch();
}

OUTPUT :
CLASS:- FY BSCIT
DIV :- A

PRACTICAL 10

 AIM :- Write a C program to simulate the


PRIORITY CPU Scheduling Algorithm
CODE:-
#include<stdio.h>
#include<conio.h>
#include<string.h>
void main()
{
int et[20],at[10],n,i,j,temp,p[10],st[10],ft[10],wt[10],ta[10];
int totwt=0,totta=0;
float awt,ata;
char pn[10][10],t[10];
//clrscr();
printf("Enter the number of process:");
scanf("%d",&n);
for(i=0; i<n; i++)
{
printf("Enter process name,arrivaltime,execution time &
priority:");
//flushall();
scanf("%s%d%d%d",pn[i],&at[i],&et[i],&p[i]);
CLASS:- FY BSCIT
DIV :- A

}
for(i=0; i<n; i++)
for(j=0; j<n; j++)
{
if(p[i]<p[j])
{
temp=p[i];
p[i]=p[j];
p[j]=temp;
temp=at[i];
at[i]=at[j];
at[j]=temp;
temp=et[i];
et[i]=et[j];
et[j]=temp;
strcpy(t,pn[i]);
strcpy(pn[i],pn[j]);
strcpy(pn[j],t);
}
}
for(i=0; i<n; i++)

{
CLASS:- FY BSCIT
DIV :- A

if(i==0)
{
st[i]=at[i];
wt[i]=st[i]-at[i];
ft[i]=st[i]+et[i];
ta[i]=ft[i]-at[i];
}
else
{
st[i]=ft[i-1];
wt[i]=st[i]-at[i];
ft[i]=st[i]+et[i];
ta[i]=ft[i]-at[i];
}
totwt+=wt[i];
totta+=ta[i];
}
awt=(float)totwt/n;
ata=(float)totta/n;

printf("\nPname\tarrivaltime\texecutiontime\tpriority\twaitin
gtime\ttatime");
for(i=0; i<n; i++)
CLASS:- FY BSCIT
DIV :- A

printf("\n%s\t%5d\t\t%5d\t\t%5d\t\t%5d\t\t
%5d",pn[i],at[i],et[i],p[i],wt[i],ta[i]);
printf("\nAverage waiting time is:%f",awt);
printf("\nAverage turnaroundtime is:%f",ata);
getch();
}

You might also like