Question

In: Computer Science

Please write in C using linux or unix.please include pictures of the terminal output. Write a...

Please write in C using linux or unix.please include pictures of the terminal output.

Write a program that will simulate non - preemptive process scheduling algorithm:

First Come – First Serve

Your program should input the information necessary for the calculation of average turnaround time including:

  • Time required for a job execution;
  • Arrival time;

The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time.

Step 1: generate the input data (totally 10 jobs) and save it in the array of structure composing the arrival time, service time, termination time, turnaround time. The service time follows the uniform distribution in the range of [5, 25], and the arrival time is generated by uniform distribution in the range of [0,10] accumulated based on the previous arrival time.

Step 2: program FCFS algorithm.

Note: be careful about the situation that one job is finished while the next job is not arrived yet, so you have the idle time between them.

Step 3: output

print out one line for each job with arrival time, start time, service, termination time, turnaround time, finally average turnaround time in the last line.

Solutions

Expert Solution

Answer :

Code :

#include<stdio.h>

int main()
{
int n=10,at[20],bt[20],wt[20],tat[20],avwt=0,avtat=0,i,j;
for(i = 0; i<n;i++){
at[i] = i;
}
for(i=0;i<n;i++)
{
bt[i] = 5 + 2*i;
}

wt[0]=0; //waiting time for first process is 0

//calculating waiting time
for(i=1;i<n;i++)
{
wt[i]=0;
for(j=0;j<i;j++)
wt[i]+=bt[j];
}

printf("\nProcess\t\tArrival Time\t\tBurst Time\tWaiting Time\tTurnaround Time");

//calculating turnaround time
for(i=0;i<n;i++)
{
tat[i]=bt[i]+wt[i];
avwt+=wt[i];
avtat+=tat[i];
printf("\nP[%d]\t\t%d\t\t\t%d\t\t%d\t\t%d",i+1,at[i],bt[i],wt[i],tat[i]);
}

avwt/=i;
avtat/=i;
printf("\n\nAverage Waiting Time:%d",avwt);
printf("\nAverage Turnaround Time:%d",avtat);

return 0;
}


Related Solutions

please use linux or unix to complete, and include pictures of the output. Modify the code...
please use linux or unix to complete, and include pictures of the output. Modify the code below to implement the program that will sum up 1000 numbers using 5 threads. 1st thread will sum up numbers from 1-200 2nd thread will sum up numbers from 201 - 400 ... 5th thread will sum up numbers from 801 - 1000 Make main thread wait for other threads to finish execution and sum up all the results. Display the total to the...
please write in c using linux or unix Write a program that will simulate non -...
please write in c using linux or unix Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
Please write in C using linux or unix. Write a program that will simulate non -...
Please write in C using linux or unix. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally 10 jobs) and...
**** Using C Sharp **** ***If possible please include screenshot of output *** **Also, if possible,...
**** Using C Sharp **** ***If possible please include screenshot of output *** **Also, if possible, please provide info from .txt files created** You are to write a program which is going to use inheritance. It should start off with the base classes Account: contains the string name, int accountnumber, double balance. Savings: Derived from Account class, it should contain double interest rate. Checkings: Derived from Account class, it should contain double overdraftlimit. CreditCard: Derived from Checkings class, it should...
using 2 semaphores and 1 mutex: (solve in simple c++ language for linux terminal and add...
using 2 semaphores and 1 mutex: (solve in simple c++ language for linux terminal and add comments please) The barber shop has one barber (a thread), one barber chair, and n chairs for waiting customers (semaphore), if any, to sit on. If there are no customers (each customer is a thread) present, the barber sits down in the barber chair and falls asleep. When a customer arrives, he has to wake up the sleeping barber. If additional customers arrive while...
Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal...
Given the Linux shell command descriptions, please write down the corresponding shell commands in a terminal window.             a) list the current directory contents with the long format             b) print the name of the working directory             c) change directory to the root directory             d) change the permissions of file "myfile" (owned by yourself) so that (1)you can read/write, but cannot execute; (2) all other users cannot read/write/execute this file.             e) make a new directory called “mydir”
use linux or c program. please provide the answer in details. Write a program that will...
use linux or c program. please provide the answer in details. Write a program that will simulate non - preemptive process scheduling algorithm: First Come – First Serve Your program should input the information necessary for the calculation of average turnaround time including: Time required for a job execution; Arrival time; The output of the program should include: starting and terminating time for each job, turnaround time for each job, average turnaround time. Step 1: generate the input data (totally...
Please Write Code in C++ and include the correct #include <header> and not a catchall such...
Please Write Code in C++ and include the correct #include <header> and not a catchall such as bits/stdc: Write a recursive, string-valued function, replace, that accepts a string and returns a new string consisting of the original string with each blank replaced with an asterisk (*) Replacing the blanks in a string involves: Nothing if the string is empty Otherwise: If the first character is not a blank, simply concatenate it with the result of replacing the rest of the...
Please complete the following functions using C. ------------------------------------------------------------ #include #include "dynarray.h" /* * This is the...
Please complete the following functions using C. ------------------------------------------------------------ #include #include "dynarray.h" /* * This is the definition of the dynamic array structure you'll use for your * implementation. Importantly, your dynamic array implementation will store * each data element as a void* value. This will permit data of any type to * be stored in your array. Because each individual element will be stored in * your array as type void*, the data array needs to be an array of...
Using SAS programming Please include the syntax and output of the information: In a study of...
Using SAS programming Please include the syntax and output of the information: In a study of factors thought to be responsible for the adverse effects of smoking on human reproduction, cadmium level determinations (nanograms per gram) were made on placenta tissue of a sample of 14 mothers who were smokers and an independent random sample of 18 nonsmoking mothers. The results were as follows- Nonsmokers: 10.0, 8.4, 12.8, 25.0, 11.8, 9.8, 12.5, 15.4, 23.5, 9.4, 25.1, 19.5, 25.5, 9.8, 7.5,...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT