Skip to main content

Posts

Showing posts from December, 2022

Assignment : 3

 Assignment : 3 Set A: i) Write the program to simulate FCFS CPU-scheduling. The arrival time and first CPU- Burst for different n number of processes should be input to the algorithm. Assume that the fixed IO waiting time (2 units). The next CPU-burst should be generated randomly. The output should give Gantt chart, turnaround time and waiting time for each process. Also find the average waiting time and turnaround time. CODE: 👇 #include<stdio.h> #include<stdlib.h> struct proc_info { int atime; int cpub; int pid;   } proc[20], temp; struct ganttchart { int stime; int pid; int etime; } gchart[20]; int i,j,ctime,n,gi=0,wtime[20],ttime[20]; void getprocs(); void start(); void dispgchart(); void addgchart(int); void disptimes(); int main() { getprocs(); ctime=0; start(); dispgchart(); disptimes(); } void getprocs() { printf("\nHow many processes:"); scanf("%d",&n); printf("\nPID\tATIME\tCPUB\n"); for(i=1; i<=n...

Assignment : 4

Assignment : 4 Set A i. Write the simulation program to implement demand paging and show the page scheduling and total number of page faults for the following given page reference string. Give input n as the number of memory frames. Reference String : 12,15,12,18,6,8,11,12,19,12,6,8,12,15,19,8 1) Implement FIFO CODE: 👇 #include<stdio.h> struct frmnode { int pno; }frames[20]; int n; int page_found(int pno) { int fno; for(fno=0; fno<n; fno++) { if(frames[fno].pno==pno) return fno; } return -1; } int get_free_frames() { int fno; for(fno=0; fno<n; fno++) { if(frames[fno].pno== -1) return(fno); } return(-1); } int get_fifo_frame() { static int fno = -1; fno = (fno+1)%n; return(fno); } int main() { int p_request[] = {5,8,10,14,10,9,5,10,8,5,1,10,9,12,10}; int size = sizeof(p_request)/4; int page_faults = 0, i, j, fno; printf("\nHow many frames:\t"); scanf("%d", &n); for(i=0; i<n; i++) { frames[i...