Question

Implement a First Come First Serve (FCFS) non-preemptive OS scheduling simulation with multiple processes, in python...

Implement a First Come First Serve (FCFS) non-preemptive OS scheduling simulation with multiple processes, in python or c++.

The simulation takes the 3 processes(listed below) and they all arrive at time 0.

A single process consists of {CPU BURST, I/O BURST, CPU BURST, I/O BURST, etc…}

The simulation accounts for all 3 processes, and does not run one process at a time.

Process1 {4,24,5,73,3,31,5,27,4,33,6,43,4,64,5,19,2}

Process2 {18,31,19,35,11,42,18,43,19,47,18,43,17,51,19,32,10}

Process3 {6,18,4,21,7,19,4,16,5,29,7,21,8,22,6,24,5}

For example at time 0, Process1 arrives and enters running state, Process2 and Process3 are in the ready queue. After 4 time units Process1 completes its first CPU burst and goes to complete its 24 time unit I/O burst. Now Process2 will start its CPU burst for 18 time units at time 4, etc....

(1) Find the total waiting time for each of the processes.

(2) Find the total execution time for each of the processes.

The next process in ready queue will execute CPU burst after the previous process is sent to complete I/O burst.

After a process’s I/O burst time has elapsed, the process is sent to the ready queue.

Waiting time is defined as time spent in the ready queue.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<iostream>
using namespace std;

void waitingTime(int x[], int c,
                       int burst_time[], int wait_time[])
{
    wait_time[0] = 0;
    for (int m = 1; m < c ; m++ )
       wait_time[m] = burst_time[m-1] + wait_time[m-1] ;
}

void turnAroundTime( int x[], int c,
               int burst_time[], int wait_time[], int t[])
{
   for (int m = 0; m < c ; m++)
       t[m] = burst_time[m] + wait_time[m];
}

void avgTime( int x[], int c, int burst_time[])
{
   int wait_time[c], t[c], total_wt = 0, total_t = 0;

   waitingTime(x, c, burst_time, wait_time);
   turnAroundTime(x, c, burst_time, wait_time, t);

   cout << "x "<< "Burst time"
       << "Waiting time" << " Turn around time\c";

   for (int m=0; m<c; m++)
   {
       total_wt = total_wt + wait_time[m];
       total_t = total_t + t[m];
       cout << " " << m+1 << "\t\t" << burst_time[m] <<"\t "
           << wait_time[m] <<"\t\t " << t[m] <<endl;
   }

   cout << "Average waiting time = "
       << (float)total_wt / (float)c;
   cout << "\nAverage turn around time = "
       << (float)total_t / (float)c;
}

int main()
{
   int x[] = { 1, 2, 3};
   int c = sizeof x / sizeof x[0];

   int burst_time[] = {4,7,11};

   avgTime(x, c, burst_time);
   return 0;
}

Add a comment
Know the answer?
Add Answer to:
Implement a First Come First Serve (FCFS) non-preemptive OS scheduling simulation with multiple processes, in python...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Implement the following 3 CPU scheduling algorithms Simulate and evaluate each with the set of eight...

    Implement the following 3 CPU scheduling algorithms Simulate and evaluate each with the set of eight processes below. Use any programming language. The program listing should be submitted with the report. FCFS (First Come First Serve) non-preemptive (partial results provided) SJF non-preemptive MLFQ Multilevel Feedback Queue (absolute priority in higher queues)             Queue 1 uses RR scheduling with Tq = 5             Queue 2 uses RR scheduling with Tq = 10             Queue 3 uses FCFS All processes enter first...

  • Please help me create this CLI CPU Scheduling Simulator in java: First Come First Serve (FCFS)...

    Please help me create this CLI CPU Scheduling Simulator in java: First Come First Serve (FCFS) Round Robin (RR) Process information The process information will be read from an input file. The format is: pid arrival_time burst_time All of fields are integer type where: pid is a unique numeric process ID arrival_time is the time when the task arrives in the unit of milliseconds burst_time the is the CPU time requested by a task, in the unit of milliseconds The...

  • Implement a program for SJF(non-preemptive) scheduling. Given n processes with their burst times and Arrival Time,...

    Implement a program for SJF(non-preemptive) scheduling. Given n processes with their burst times and Arrival Time, the task is to find average waiting time and average turn around time and completion time using SJF scheduling algorithm. Language in C • Completion Time: Time at which process completes its execution. • Turn Around Time: Time Difference between completion time and arrival time. Turn Around Time = Completion Time – Arrival Time • Waiting Time: Time Difference between turn around time and...

  • Consider the following set of processes, with the length of the CPU-burst time given in milliseconds:

    Consider the following set of processes, with the length of the CPU-burst time given in milliseconds:Processburst TimePriorityP1103P211P323P414P552For each of the scheduling algorithms, FCFS, Shortest-Job-First (SJF, non-preemptive), Priority (smaller priority number implies higher scheduling priority), and RR (quantum = 1) do the following.Draw a Gantt chart to show how these processes would be scheduled.Give the turnaround time (total time from the first arrival into ready state until CPU-burst is completed) of each process.Give the waiting time (total time spent in the Ready state) of each process.Give...

  • This assignment requires you to create simulations for different scheduling algorithms commonly employed by operating systems...

    This assignment requires you to create simulations for different scheduling algorithms commonly employed by operating systems to achieve multiprogramming. All problems in this assignment assume the following: The simulations you will be creating are for a uniprocessor system (single CPU). Processes in these simulations will require CPU bursts of one or more time units followed by I/O bursts of one or more time units. For simplicity’s sake, when more than one process is executing its I/O burst at the same...

  • QUESTION 3 Consider the following set of processes: Priority Process Arrival Time A 0 B 1...

    QUESTION 3 Consider the following set of processes: Priority Process Arrival Time A 0 B 1 C 6 * Lower number means higher priority Burst Time (ms) 5 3 4 Draw in a paper sheet 4 Gantt charts that illustrate the execution of these processes using the following scheduling algorithms: FCFS, Non-Preemptive SJF, Shortest-Remaining-Time-First (SRTF), Non-Preemptive Priority (NPP), and RR (quantum time = 2) scheduling algorithms, then fill the following tabic accordingly. (Note: If a new process arrives at the...

  • 4. Consider a ready queue with four processes :- Process Arrival Time Burst Time (ms) P1...

    4. Consider a ready queue with four processes :- Process Arrival Time Burst Time (ms) P1 Priority P2 P3 P4 P5 For each of the following CPU scheduling algorithms, determine the turnaround and average waiting time for each of the process :- a. Shortest remaining Time First b. Shortest Job First C. Priority Scheduling (Both pre-emptive and non-preemptive) d. Round Robin (quantum is 1 ms)

  • Assume that you have four different processes with the following attributes: Process   Arrival time.   CPU Burst....

    Assume that you have four different processes with the following attributes: Process   Arrival time.   CPU Burst.   I/O Burst Total CPU time A. 0 4 4 9 B 3 2 3 7 C 6 5 1 11 D 12 1 1 5 As we did in class, perform a scheduling simulation using these four processes according to the following algorithms: 1) First Come First Serve 2) Round Robin with time slice = 1 3) Round Robin with time slice = 3...

  • The following processes are being scheduled using a preemptive, roundrobin scheduling algorithm. Each process is assigned...

    The following processes are being scheduled using a preemptive, roundrobin scheduling algorithm. Each process is assigned a numerical priority, with a higher number indicating a higher relative priority. In addition to the processes listed below, the system also has an idle task (which consumes no CPU resources and is identified as I ). This task has priority 0 and is scheduled whenever the system has no other available processes to run. The length of a time quantum is 5 units....

  • (30 points) Assume you have three processes with the following attributes running on a single CPU...

    (30 points) Assume you have three processes with the following attributes running on a single CPU (uniprocessor system): Process 1/0 Burst Total CPU Time Arrival Time CPU Burst | 05 22 12 B 7 10 C D Create three scheduling simulations for these processes using the following algorithms: a. First Come First Served (FCFS) b. Round Robin, Time Slice = 2 c. Shortest Job (CPU Burst Time) First with NO Preemption Use the simulation format we covered in class to...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT