Thanks to visit codestin.com
Credit goes to www.scribd.com

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

Practical

The document outlines practical exercises for studying software and hardware requirements of various operating systems (Windows, Linux, Unix) and implementing DOS commands. It includes detailed instructions for accessing the command prompt and executing basic DOS commands, as well as C programs for implementing FCFS and SJF CPU scheduling algorithms. The document provides code examples and expected outputs for both scheduling algorithms.

Uploaded by

Sonika Nagar
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)
9 views9 pages

Practical

The document outlines practical exercises for studying software and hardware requirements of various operating systems (Windows, Linux, Unix) and implementing DOS commands. It includes detailed instructions for accessing the command prompt and executing basic DOS commands, as well as C programs for implementing FCFS and SJF CPU scheduling algorithms. The document provides code examples and expected outputs for both scheduling algorithms.

Uploaded by

Sonika Nagar
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

Practical 1

Study of software and hardware requirements of various Operating Systems


(Windows/Linux/Unix) and Implementation of DOS commands on command
prompt.
you'll need to understand their software and hardware requirements, and then practice
using the command prompt (or terminal) to execute basic DOS commands.
1. Software and Hardware Requirements:
 Windows:
 Software: A Windows operating system (e.g., Windows 10, 11) is the primary
software requirement.
 Hardware: A computer with a processor (CPU), RAM, storage (hard drive or
SSD), and a basic input/output system (BIOS or UEFI).
 Linux/Unix:
 Software: A Linux distribution (e.g., Ubuntu, Fedora, Debian) or a Unix-based
operating system (e.g., macOS, FreeBSD).
 Hardware: Similar to Windows, a computer with a processor, RAM, storage,
and BIOS/UEFI.
 DOS (Disk Operating System):
 Software: MS-DOS (Microsoft Disk Operating System) was the original
command-line operating system for IBM PC compatible computers, but is now
largely obsolete.
 Hardware: Early IBM PC compatible computers with a 8086 or 8088
processor, floppy disk drives, and a monitor.
2. Implementing DOS Commands on Command Prompt (cmd.exe):
 Accessing Command Prompt:
 In Windows, you can access it by searching for "cmd" in the Start Menu or by
pressing the Windows key + R, typing "cmd", and pressing Enter.
 Basic DOS Commands:
 dir: Lists files and directories in the current directory.
 cd: Changes the current directory.
 mkdir: Creates a new directory.
 del: Deletes files.
 ren: Renames files or directories.
 cls: Clears the screen.
 exit: Exits the command prompt.
 Examples:
 dir - Lists all files and folders in the current directory.
 cd Documents - Changes the current directory to the "Documents" folder.
 mkdir NewFolder - Creates a new folder named "NewFolder".
 del myfile.txt - Deletes the file "myfile.txt".
 ren oldname.txt newname.txt - Renames the file "oldname.txt" to
"newname.txt".
 cls - Clears the screen.
 exit - Closes the command prompt window.
Practical 2
Write a program in C to implement FCFS CPU scheduling Algorithm.

CODE:
#include<stdio.h>
int main()
{
int p[10],at[10],bt[10],ct[10],tat[10],wt[10],i,j,temp=0,n;
float awt=0,atat=0;
printf("enter no of proccess you want:");
scanf("%d",&n);
printf("enter %d process:",n);
for(i=0;i<n;i++)
{
scanf("%d",&p[i]);
}
printf("enter %d arrival time:",n);
for(i=0;i<n;i++)
{
scanf("%d",&at[i]);
}
printf("enter %d burst time:",n);
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
}
// sorting at,bt, and process according to at
for(i=0;i<n;i++)
{
for(j=0;j<(n-i);j++)
{
if(at[j]>at[j+1])
{
temp=p[j+1];
p[j+1]=p[j];
p[j]=temp;
temp=at[j+1];
at[j+1]=at[j];
at[j]=temp;
temp=bt[j+1];
bt[j+1]=bt[j];
bt[j]=temp;
} } }
/* calculating 1st ct */
ct[0]=at[0]+bt[0];
/* calculating 2 to n ct */
for(i=1;i<n;i++)
{
//when proess is ideal in between i and i+1
temp=0;
if(ct[i-1]<at[i])
{
temp=at[i]-ct[i-1];
}
ct[i]=ct[i-1]+bt[i]+temp;
}
/* calculating tat and wt */
printf("\np\t A.T\t B.T\t C.T\t TAT\t WT");
for(i=0;i<n;i++)
{
tat[i]=ct[i]-at[i];
wt[i]=tat[i]-bt[i];
atat+=tat[i];
awt+=wt[i];
}
atat=atat/n;
awt=awt/n;
for(i=0;i<n;i++)
{
printf("\nP%d\t %d\t %d\t %d \t %d \t %d",p[i],at[i],bt[i],ct[i],tat[i],wt[i]);
}
printf("\naverage turnaround time is %f",atat);

printf("\naverage wating timme is %f",awt);


return 0;
}
OUTPUT:
Practical 3
Write a program in C to implement SJF CPU scheduling Algorithm.

CODE:
#include<stdio.h>
#include<stdlib.h>
void swap(int *x, int *y)
{
int temp=*x;
*x=*y;
*y=temp;
}
void sortat(int p[], int at[], int bt[], int n)
{
int i, j;
for(i=0;i<n;i++)
{
for(j=i+1;j<n;j++)
{ /* sort the process having less arrival*/
if(at[i]>at[j])
{
swap(&p[i], &p[j]);
swap(&at[i], &at[j]);
swap(&bt[i], &bt[j]);
}
/* if two processes have the same arrival time than sort them having less burst time */
else if(at[i]==at[j])
{
if(bt[i]>bt[j])
swap(&p[i], &p[j]);
swap(&at[i], &at[j]);
swap(&bt[i], &bt[j]);
}}}}
/* calculate turnaround time and waiting time */
void tatwt( int ct[], int at[], int bt[], int tat[], int wt[], int n)
{
int i;
for(i=0;i<n;i++)
{
tat[i]=ct[i]-at[i];
wt[i]=tat[i]-bt[i];
}}
int main()
{
int *p, *at, *bt, *tat, *wt, *ct, pos, i, j, min=1000, n;
float awt=0, atat=0;
printf("\nenter the number of process:");
scanf("%d", &n);
p=(int*)malloc(n*sizeof(int));
at=(int*)malloc(n*sizeof(int));
bt=(int*)malloc(n*sizeof(int));
ct=(int*)malloc(n*sizeof(int));
wt=(int*)malloc(n*sizeof(int));
tat=(int*)malloc(n*sizeof(int));
printf("enter the process");
for(i=0;i<n;i++)
{
scanf("%d",&p[i]);
}
printf("enter the arrival time");
for(i=0;i<n;i++)
{
scanf("%d",&at[i]);
}
printf("enter the burst time");
for(i=0;i<n;i++)
{
scanf("%d",&bt[i]);
}
sortat(p, at, bt, n);
ct[0]=at[0] + bt[0];
for(i=1; i<n; i++)
{
for(j=i; j<n; j++)
{
if(at[j]<=ct[i-1])
{
if(bt[j]<min)
{
min=bt[j];
pos=j;
} } }
swap(&p[i], &p[pos]);
swap(&at[i], &at[pos]);
swap(&bt[i], &bt[pos]);
min=1000;
ct[i]=ct[i-1]+bt[i];
}
tatwt(ct, at, bt, tat, wt, n);
printf("\np\t at\t bt\t ct\t tat\t wt");
for(i=0;i<n;i++)
{
printf("\n%d\t %d\t %d\t %d\t %d\t %d",p[i], at[i], bt[i], ct[i], tat[i], wt[i]);
}
for(i=0;i<n;i++)
{
atat+=tat[i];
awt+=wt[i];
}
// average turnaround time and average waiting time
atat=atat/n;
awt=awt/n;
printf("\n avg tat=%.2f and avg wt=%.2f",atat, awt);
return 0;
}
OUTPUT:

You might also like