Practical
Practical
Networking Commands :
ping: Test network connectivity to a host.
ifconfig: Display network interface information.
traceroute: Trace the route packets take to reach a
destination.
wget: Download files from the internet.
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
int main()
{
fork();
printf("\n Hello World");
}
Save the file: Save the file in a directory you can easily
access through the terminal.
Compile the code: In the terminal, navigate to the
directory where you saved the file using
the cd command. Then, compile the C code using
the gcc compiler:
Code :
Code :
./a.out
CODE:
#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
int main()
{
fork();
fork();
fork();
printf("\n Hello World");
}
OUTPUT:
Practical – 03
int main() {
int i, n, time = 0, remain;
int bt[10], rt[10], quantum;
OUTPUT:
Practical – 04
int main() {
int n, i, j;
// Output
printf("\nProcess\tBT\tPriority\tWT\tTAT\n");
for(i = 0; i < n; i++) {
printf("%d\t%d\t%d\t\t%d\t%d\n", p[i], bt[i],
priority[i], wt[i], tat[i]);
}
return 0;
}
Practical – 05
Processing:
Output:
A table showing Process ID, Burst Time, Waiting Time, and Turnaround
Time
Code :
#include<stdio.h>
int main()
{
int n,exetime[100],i;
int wtime = 0 , tat = 0;
float awt = 0 , atat = 0 , _awt = 0, _atat = 0;
printf("\n Enter the no of process = ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the execution time for each process = ");
scanf("%d",&exetime[i]);
}
printf("\n \n pid \t \t BT \t \t WT \t \t TAT");
for(i=0;i<n;i++)
{
tat = exetime[i] + wtime;
printf("\n %d \t \t %d \t \t %d \t \t %d", i+1 , exetime[i] , wtime , tat);
_awt = _awt + wtime;
_atat = _atat + tat;
wtime = wtime + exetime[i];
}
awt=_awt/n;
atat=_atat/n;
printf("\n Avg.waiting time %f",awt);
printf("\n Avg.turnaround time %f ",atat);
}
OUTPUT:
Practical – 06
Processing:
Output:
CODE :
#include<stdio.h>
int main()
{
int n,exetime[100],i;
int wtime = 0 , tat = 0;
float awt = 0 , atat = 0 , _awt = 0, _atat = 0;
printf("\n Enter the no of process = ");
scanf("%d",&n);
for(i=0;i<n;i++)
{
printf("Enter the execution time for each process = ");
scanf("%d",&exetime[i]);
}
for(i=0;i<n-1;i++)
{
for(int j=i+1;j<n;j++)
{
If(exetime[i] < exetime[j])
{
int temp = exetime[i];
exetime[i] = exetime[j];
exetime[j] = temp;
}
}
}
printf("\n \n pid \t \t BT \t \t WT \t \t TAT");
for(i=0;i<n;i++)
{
tat = exetime[i] + wtime;
printf("\n %d \t \t %d \t \t %d \t \t %d", i+1 , exetime[i] ,
wtime , tat);
_awt = _awt + wtime;
_atat = _atat + tat;
wtime = wtime + exetime[i];
}
awt=_awt/n;
atat=_atat/n;
printf("\n Avg.waiting time %f",awt);
printf("\n Avg.turnaround time %f ",atat);
}
OUTPUT :
Practical – 07
SOURCE CODE:
#include <stdio.h>
int main() {
int n, i, j;
// Output
printf("\nProcess\tBT\tPriority\tWT\tTAT\n");
for(i = 0; i < n; i++) {
printf("%d\t%d\t%d\t\t%d\t%d\n", p[i], bt[i],
priority[i], wt[i], tat[i]);
}
return 0;
}
OUTPUT:
Practical – 08
Processing:
Output:
CODE:
#include <stdio.h>
int main() {
int i, n, time = 0, remain;
int bt[10], rt[10], quantum;
return 0;
}
OUTPUT: