You are on page 1of 4

CS604

Assignment No 2
Student Name:Sheharyar Nadeem

Student iD;Bc180405023

Question No 1:

Solution:

Program1
#include<stdio.h>

#include<string.h>

#include<sys/stat.h>

#include<sys/types.h>

#include<sys/errno.h>

#include<fcntl.h>

#include<unistd.h>

#include<stdlib.h>

int main()

int fd ;

char * fifo_one = "/tmp/fifo_one" ;

mkfifo(fifo_one , 0666) ;

char buffer [80] ;

fd= open(fifo_one , O_RDONLY) ;

read( fd , buffer , sizeof( buffer) );

//printf("") ;

close(fd) ;
}

Program2
#include<string.h>

#include<sys/stat.h>

#include<sys/types.h>

#include<sys/errno.h>

#include<fcntl.h>

#include<unistd.h>

#include<stdlib.h>

#include<stdio.h>

int main()

int fd1 ;

char * fifo_one = "/tmp/fifo_one" ;

mkfifo(fifo_one , 0666) ;

char buffer [80] ;

fd1 = open(fifo_one , O_WRONLY) ;

write( fd1 , buffer , sizeof( buffer) );

printf("Bc180405023 Sheharyar Nadeem\n") ;

close(fd1) ;

}
Screenshot:

______________

QuestionNo 2:
Consider the following threeprocesses, with the Arrival time and CPU burst time,is given in
milliseconds:

A. Draw a Gantt chart showing the execution of three processes using the Shortest
Remaining Time First (SRTF) scheduling.
B. Find the turnaround time of each process for the SRTF Shortest Remaining Time First
scheduling algorithm as per the Gantt chart.
C. Calculate the waiting time for the three processes for the SRTF Shortest Remaining Time
First scheduling algorithm as per the Gantt chart?
Solution:

Process Arrival Time Burst Time

P1 0.0 3

P4 1.0 8

P3 3.0 6

P1 P1 P1 P3 P3 P3 P3 P3 P3 P4 P4 P4 P4 P4 P4 P4 P4
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17

P1 P3 P2
0 3 9 17

Process Arrival TIme Brust TIme Catch Time TurnAround Waiting


TIme Time
P1 0.0 3 3 3 0
P2 1.0 8 17 16 8
P3 3.0 6 9 6 0

____________________

You might also like