Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

IN JAVA A simulation mimics the execution of n different processes under different scheduling algorithms. The simulation maintains a table that reflects the current state

IN JAVA

A simulation mimics the execution of n different processes under different scheduling algorithms. The simulation maintains a table that reflects the current state of the system:

Process Active Arrival time Total CPU time Remaining CPU time Turnaround time Priority Level
...
p 0/1 A T R TT Li
...

The table is initialized as follows:

  • The field "active" indicates whether the process is currently competing for the CPU. The value becomes 1 at the time of process arrival and 0 at the time of process termination. Initially, the value is set to 1 for all processes with arrival time A = 0.
  • Each A is an integer chosen randomly from a uniform distribution between 0 and some value k (inclusive), where k is a simulation parameter given to your program.
  • Each L is an integer chosen randomly from a uniform distribution between 1 and 10 (only used for the last scheduling algorithm).
  • Each T is an integer chosen randomly from a normal (Gaussian) distribution with an average d and a standard deviation v, where d and v are simulation parameters.
  • Each R is initialized to T, since prior to execution, the remaining time is equal to the total CPU time required.

The simulation maintains the current time, t, which is initialized to 0 and is incremented after each simulation step. Each simulation step then consists of the following actions:

repeat until R == 0 for all n processes /* repeat until all processes have terminated */ while no process is active, increment t /* if no process is ready to run, just advance t */ choose active processes p to run next according to scheduling algorithm /* Ex: FIFO, SJF, SRT */ decrement R /* p has accumulated 1 CPU time unit */ if R == 0 /* process i has terminated */ set active flag of p = 0 /* process i is excluded from further consideration */ TT = t - A /* the turnaround time of process i is the time since arrival, TT, until the current time t */ compute the average turnaround time, ATT, by averaging all values TT

Assignment

  • Implement the above simulation for the 4 scheduling algorithms, FIFO, SJF, SRT, and Preemptive Multi-level Priority Scheduling with RR (Q=q) as the tie-breaker.
  • Assume that simulation parameters are given to your simulation program as command-line arguments:
    • number of processes n
    • a value for k, which is the time interval during which processes may arrive. Ex: k = 1000.
    • The mean and standard deviation of total CPU times d and v
    • Time quantum q for the last scheduling algorithm.
  • Using a random number generator, derive n arrival times, A, for all processes, distributed uniformly within the interval [0 : k].
  • Given the average total CPU time, d, and a standard deviation, v, derive n total CPU times, T, using a normal (Gaussian) distribution.
  • The values d and v should be selected relative to k. The value k/n represents the frequency of process arrivals. When d is much smaller than k/n, then most processes run in isolation, without having to compete with other processes for the CPU. As a result, all scheduling algorithms should produce similar results. On the other hand, when d is much larger than k/n, then many processes will overlap in time and compete for the CPU. Consequently, different scheduling algorithms should yield different results.
  • To compare the different algorithms, plot the values d/ATT over d. The value d/ATT shows how competition for CPU slows down the processes. The smaller the value, the worse the overall performance. The ideal case is d/ATT = 1, which indicates that all processes ran without any delays.
    • d varies from k/n to 25k/n
    • v is set to d/4 and the distribution of Tis is truncated normal distribution (with minimum value = 1)
    • (n,k) = (100,1000), (500,10000), (500,5000), (1000, 10000) (one plot for each value).
    • q = d+v

THIS IS ALL THE INFO I WAS GIVEN

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

4th Edition

0805360476, 978-0805360479

More Books

Students also viewed these Databases questions

Question

2. Why has the conflict escalated?

Answered: 1 week ago

Question

1. What might have led to the misinformation?

Answered: 1 week ago