×
You can use excuses to convince others, but how will you convince yourself?
--Your friends at LectureNotes
Close

Lab Manuals for Operating Systems - OS By sri lekha

  • Operating Systems - OS
  • Practical
  • 29 Views
  • Uploaded 3 months ago
0 User(s)
Download PDFOrder Printed Copy

Share it with your friends

Leave your Comments

Text from page-1

O S LAB MANUAL MLRITM OPERATING SYSTEMS EXPERIMENT : 1 NAMEOF THE EXPERIMENT: Simulate the following CPU Scheduling Algorithms a) FCFS b) SJF c) Round Robin d) Priority AIM: Using CPU scheduling algorithms find the min & max waiting time. HARDWARE REQUIREMENTS: Intel based Desktop Pc RAM of 512 MB SOFTWARE REQUIREMENTS: Turbo C/ Borland C. THEORY: CPU SCHEDULING Maximum CPU utilization obtained with multiprogramming CPU–I/O Burst Cycle – Process execution consists of a cycle of CPU execution and I/O wait CPU burst distribution

Text from page-2

a) First-Come, First-Served (FCFS) Scheduling Process Burst Time P1 24 P2 3 P3 3 Suppose that the processes arrive in the order: P1 , P2 , P3 The Gantt Chart for the schedule is: 0 24 Waiting time for P1 = 0; P2 = 24; P3 = 27 Average waiting time: (0 + 24 + 27)/3 = 17 ALGORITHM 1. Start 2. Declare the array size 3. Read the number of processes to be inserted 4. Read the Burst times of processes 5. calculate the waiting time of each process wt[i+1]=bt[i]+wt[i] 6. calculate the turnaround time of each process tt[i+1]=tt[i]+bt[i+1] 7. Calculate the average waiting time and average turnaround time. 8. Display the values 9. Stop 2 27 30

Text from page-3

PROGRAM: #include<stdio.h> #include<conio.h> void main() { int i,j,bt[10],n,wt[10],tt[10],w1=0,t1=0; float aw,at; clrscr(); printf("enter no. of processes:\n"); scanf("%d",&n); printf("enter the burst time of processes:"); for(i=0;i<n;i++) scanf("%d",&bt[i]); for(i=0;i<n;i++) { wt[0]=0; tt[0]=bt[0]; wt[i+1]=bt[i]+wt[i]; tt[i+1]=tt[i]+bt[i+1]; w1=w1+wt[i]; t1=t1+tt[i]; } aw=w1/n; at=t1/n; printf("\nbt\t wt\t tt\n"); for(i=0;i<n;i++) printf("%d\t %d\t %d\n",bt[i],wt[i],tt[i]); printf("aw=%f\n,at=%f\n",aw,at); getch(); } INPUT Enter no of processes 3 enter bursttime 12 8 20 EXPECTED OUTPUT bt wt tt 12 0 12 8 12 20 20 20 40 aw=10.666670 at=24.00000 3

Text from page-4

VIVA QUESTIONS 1. What is First-Come-First-Served (FCFS) Scheduling? 2. Why CPU scheduling is required? 3. Which technique was introduced because a single job could not keep both the CPU and the I/O devices busy? 1) Time-sharing 2) SPOOLing 3) Preemptive scheduling 4) Multiprogramming 4. CPU performance is measured through ________. 1) Throughput 2) MHz 3) Flaps 4) None of the above 5. Which of the following is a criterion to evaluate a scheduling algorithm? 1 CPU Utilization: Keep CPU utilization as high as possible. 2 Throughput: number of processes completed per unit time. 3 Waiting Time: Amount of time spent ready to run but not running. 4 All of the above 4

Lecture Notes