Professional Documents
Culture Documents
CODE:
pid[k] = k + 1;
}
}
}
}
System.out.println();
for(int i = 1; i<numberOfProcess; i++) {
}
}
System.out.println("******************************************");
System.out.println("Process\t\tAT\t\tBT\t\tCT\t\tTAT\t\tWT");
System.out.println("*******************************************");
System.out.println(pid[i] + "\t\t" + ar[i] + "\t\t" + bt[i] + "\t\t" + ct[i] + "\t\t" + ta[i] + "\t\t" +
wt[i]);
}
}
/*
4
******************************************
*******************************************
*/
PRACTICAL NO. 5
CODE:
{
Scanner sc = new Scanner(System.in);
{
f[i] = 0;
}
while(true)
{
if (tot == n)
break;
{
min=bt[i];
c=i;
}
}
if (c==n)
st++;
else
{
ct[c]=st+bt[c];
st+=bt[c];
ta[c]=ct[c]-at[c];
wt[c]=ta[c]-bt[c];
f[c]=1;
tot++;
}
}
{
System.out.println(pid[i]+"\t"+at[i]+"\t"+bt[i]+"\t"+ct[i]+"\t"+ta[i]+"\t"+wt[i]);
}
sc.close();
}
}
/*
enter no of process:
4
average wt is 5.2
*/PRACTICAL NO.6
CODE:
tq = inp.nextInt();
}
}
queue[i] = 0;
}
timer++;
queue[0] = 1;
while(true) {
if(temp_burst[i] != 0) {
break;
}
}
if(flag)
break;
temp_burst[queue[0]-1] -= 1;
timer += 1;
ctr++;
}
}
if(queue[n-1] == 0) {
}
}
}
else
if(idle) {
timer++;
}
}
}
}
System.out.println(i+1 + "\t\t" + arrival[i] + "\t\t" + burst[i] + "\t\t" + turn[i] + "\t\t" + wait[i] + "\
n");
}
for(int i = 0; i < n; i++) {
}
System.out.println("\nAverage wait time : " + (avgWait/n) + "\naverage Turn Around Time : " +
(avgTT/n));
}
public static void queueUpdation(int queue[], int timer, int arrival[], int n, int maxProcessIndex) {
if(queue[i] == 0) {
zeroIndex = i;
break;
}
}
return;
}
public static void checkNewArrival(int timer, int arrival[], int n, int maxProcessIndex, int queue[]) {
}
}
}
if(newArrival)
}
}
}
}
}
PRACTICAL NO.7
import java.util.Scanner;
np = input.nextInt();
nr = input.nextInt();
}
System.out.println();
}
}
}
System.out.println();
}
}
}
System.out.println();
}
input.close();
}
}
}
}
}
}
cal_need();
int c = 0;
c++;
}
}
}
}
else
}
obj.input();
obj.algorithm();
}
PRACTICAL NO.8
CODE:
import java.io.*;
}
}
System.out.println();
search = j;
hit++;
break;
}
}
fault++;
pointer++;
pointer = 0;
}
}
System.out.println();
}
}
PRACTICAL NO. 9
Q. . Write a Java program that implements the LRU page-replacement algorithm
CODE:
pos = i;
}
}
n = s.nextInt();
System.out.println("Enter the page reference string -> ");
frames[i] = 0;
counter[i] = 0;
}
flag = 1;
break;
}
}
if(flag == 0) {
if(frames[j] == 0) {
pageFault++;
break;
}
}
}
if(flag == 0) {
pageFault++;
}
System.out.println();
}
}
}
PRACTICAL NO.10
import java.io.IOException;
try{
else
catch(IOException e){
Output:-