Question

In: Computer Science

Please include all inputs and outputs in details with pictures: General rules: Create homework, compose specifications...

Please include all inputs and outputs in details with pictures:

General rules: Create homework, compose specifications or any text by using a common document-creation tool, such as Microsoft® Word.

Detailed Hints: Refer to the wwweb or lecture notes for this class to design, implement, and debug solid SW solutions. Be concise, complete, and precise.

Abstract: Compute the performance data for the schedulers of three types of Operating Systems. Do not get scared! Only the timing for each scheduler is of interest. You can compute these timing data by hand or by actually implementing a simulator. Either solution is feasible and permitted. The simulator measures key performance data, such as throughput, wait time, and turn-around time. You may also manually compute these numbers without having to run them in a simulation environment.

If you chose to “manually” compute the data, i.e. without implementing a SW simulator, the amount of “generated performance data” is allowed to be way less detailed than what is suggested here.

One OS is a strict batch system with a non-preemptive First Come First Serve (FCFS) scheduler. The second OS uses a non-preemptive, high-priority first (HPF) scheduler, while the third OS uses a preemptive round robin (RR) scheduler with a variable time-quantum with varying context switch overhead. Design meaningful input data, run them through all schedulers, generate output data, and interpret and discuss the results. To start your simulations, use the sample data from this HW assignment. In addition, provide 2 additional, meaningful input scenarios, more complex than the samples given here.

Detail: HomeWork 1 consists of the following parts with equal weight each:

  • Compute performance data for the scheduler of a non-preemptive FCFS batch system
  • Ditto for a non-preemptive HPF batch system, and
  • Ditto for a preemptive RR scheduler; you’ll vary time quantum and overhead.
  • Invent meaningful input data; run them through your schedulers to produce output
  • Discuss the generated data. Hand in your discussion in typed form

Input: Input to the schedulers is a list of processes, for which you happen to know the execution time in milliseconds. For your program input, each process is represented by a triple of decimal numbers id, time, priority. These multiple processes are scheduled and compete for the CPU resource. Here id is the name of the process; time is the time in milliseconds that process id needs to run to completion, and priority is the priority of process id. A plausible input sample for two processes with process id 1 and process id 4 is:

1          2          3

4          50        6

Depending on the scheduler, priority may be ignored. The meaning of triples is as follows:

1   2 3          process 1 uses 2 milliseconds to run, has priority 3

4 50 6           process 4 uses 50 milliseconds, has priority 6, with 0 being the highest

Use the definitions below to compute for each process Throughput, Wait Time, and Turn-around Time. Compute these for each of the 3 schedulers; also compute the average for all processes.

For the preemptive RR scheduler, vary the time quantum q from 1 to 5 milliseconds (ms). Also, for each q selected, vary the overhead o of a context switch from 0 ms up to q itself. There is no need to vary the o beyond q. When a process scheduled by the RR system has received all time needed to completion, do not add a final o unit in the computation of the total time for that process. Also the first time around, act as if the initial schedule overhead o is 0. Use the sample outputs below as a guide for the detail you should generate for this HW.

Definitions:

Throughput:                    Number of jobs (processes) completed per time unit

Waiting Time:                  The total time a process is in Ready Queue

Average Waiting Time:    Average Waiting Time of n processes is: total waiting time by n

Turn-around Time:          span of time of submission to completion time

       

Example 1:

Enter triples: process id, time in ms, and priority:

For example:

1 12 0

3 9 1

2 99 9

process 1 needs 12 ms and has priority 0, very high,

process 3 needs 9 ms and has priority 1.

and so on ...

1 2 3

2 1 2

Process list in FCFS order as entered:

1 2 3

2 1 2

End of list.

fcfs wait of p1 = 0

fcfs wait of p2 = 2

average wait for 2 procs = 1

fcfs turn-around time for p1 = 2

fcfs turn-around time for p2 = 3

average turn-around for 2 procs = 2.5

fcfs throughput for 2 procs = 0.666667 proc/ms

<><> end FCFS <><>

Process list in HPF order:

2 1 2

1 2 3

End of list.

hpf wait of p2 = 0

hpf wait of p1 = 1

average wait time for 2 procs = 0.5

hpf turn-around for p2 = 1

hpf turn-around for p1 = 3

average turn-around for 2 procs = 2

hpf throughput for 2 procs = 0.666667 proc/ms

<><> end HPF schedule <><>

Process list for RR in order entered:

1 2 3

2 1 2

End of list.

preemptive RR schedule, quantum = 1 overhead = 0

RR TA time for finished p2 = 2, needed: 1 ms, and: 1 time slices.

RR TA time for finished p1 = 3, needed: 2 ms, and: 2 time slices.

RR Throughput, 2 p, with q: 1, o: 0, is: 0.666667 p/ms, or 666.667 p/us

Average RR TA, 2 p, with q: 1, o: 0, is: 2.5

preemptive RR schedule, quantum = 1 overhead = 1

RR TA time for finished p2 = 3, needed: 1 ms, and: 1 time slices.

RR TA time for finished p1 = 5, needed: 2 ms, and: 2 time slices.

RR Throughput, 2 p, with q: 1, o: 1, is: 0.4 p/ms, or 400 p/us

Average RR TA, 2 p, with q: 1, o: 1, is: 4

preemptive RR schedule, quantum = 2 overhead = 0

RR TA time for finished p1 = 2, needed: 2 ms, and: 1 time slices.

RR TA time for finished p2 = 3, needed: 1 ms, and: 1 time slices.

RR Throughput, 2 p, with q: 2, o: 0, is: 0.666667 p/ms, or 666.667 p/us

Average RR TA, 2 p, with q: 2, o: 0, is: 2.5

preemptive RR schedule, quantum = 2 overhead = 1

RR TA time for finished p1 = 2, needed: 2 ms, and: 1 time slices.

RR TA time for finished p2 = 4, needed: 1 ms, and: 1 time slices.

RR Throughput, 2 p, with q: 2, o: 1, is: 0.5 p/ms, or 500 p/us

Average RR TA, 2 p, with q: 2, o: 1, is: 3

preemptive RR schedule, quantum = 2 overhead = 2

RR TA time for finished p1 = 2, needed: 2 ms, and: 1 time slices.

RR TA time for finished p2 = 5, needed: 1 ms, and: 1 time slices.

RR Throughput, 2 p, with q: 2, o: 2, is: 0.4 p/ms, or 400 p/us

Average RR TA, 2 p, with q: 2, o: 2, is: 3.5

<><> end preemptive RR schedule <><>

Example 2:

Enter triples: process id, time in ms, and priority:

For example:

1 12 0

3 9 1

2 99 9

process 1 needs 12 ms and has priority 0, very high,

process 3 needs 9 ms and has priority 1.

and so on ...

1 10 5

2 8 1

3 12 7

Process list in FCFS order as entered:

1 10 5

2 8 1

3 12 7

End of list.

fcfs wait of p1 = 0

fcfs wait of p2 = 10

fcfs wait of p3 = 18

average wait for 3 procs = 9.33333

fcfs turn-around time for p1 = 10

fcfs turn-around time for p2 = 18

fcfs turn-around time for p3 = 30

average turn-around for 3 procs = 19.3333

fcfs throughput for 3 procs = 0.1 proc/ms

<><> end FCFS <><>

Process list in HPF order:

2 8 1

1 10 5

3 12 7

End of list.

hpf wait of p2 = 0

hpf wait of p1 = 8

hpf wait of p3 = 18

average wait time for 3 procs = 8.66667

hpf turn-around for p2 = 8

hpf turn-around for p1 = 18

hpf turn-around for p3 = 30

average turn-around for 3 procs = 18.6667

hpf throughput for 3 procs = 0.1 proc/ms

<><> end HPF schedule <><>

Process list for RR in order entered:

1 10 5

2 8 1

3 12 7

End of list.

preemptive RR schedule, quantum = 1 overhead = 0

RR TA time for finished p2 = 23, needed: 8 ms, and: 8 time slices.

RR TA time for finished p1 = 27, needed: 10 ms, and: 10 time slices.

RR TA time for finished p3 = 30, needed: 12 ms, and: 12 time slices.

RR Throughput, 3 p, with q: 1, o: 0, is: 0.1 p/ms, or 100 p/us

Average RR TA, 3 p, with q: 1, o: 0, is: 26.6667

preemptive RR schedule, quantum = 1 overhead = 1

RR TA time for finished p2 = 45, needed: 8 ms, and: 8 time slices.

RR TA time for finished p1 = 53, needed: 10 ms, and: 10 time slices.

RR TA time for finished p3 = 59, needed: 12 ms, and: 12 time slices.

RR Throughput, 3 p, with q: 1, o: 1, is: 0.0508475 p/ms, or 50.8475 p/us

Average RR TA, 3 p, with q: 1, o: 1, is: 52.3333

preemptive RR schedule, quantum = 2 overhead = 0

RR TA time for finished p2 = 22, needed: 8 ms, and: 4 time slices.

RR TA time for finished p1 = 26, needed: 10 ms, and: 5 time slices.

RR TA time for finished p3 = 30, needed: 12 ms, and: 6 time slices.

RR Throughput, 3 p, with q: 2, o: 0, is: 0.1 p/ms, or 100 p/us

Average RR TA, 3 p, with q: 2, o: 0, is: 26

preemptive RR schedule, quantum = 2 overhead = 1

RR TA time for finished p2 = 32, needed: 8 ms, and: 4 time slices.

RR TA time for finished p1 = 38, needed: 10 ms, and: 5 time slices.

RR TA time for finished p3 = 44, needed: 12 ms, and: 6 time slices.

RR Throughput, 3 p, with q: 2, o: 1, is: 0.0681818 p/ms, or 68.1818 p/us

Average RR TA, 3 p, with q: 2, o: 1, is: 38

preemptive RR schedule, quantum = 2 overhead = 2

RR TA time for finished p2 = 42, needed: 8 ms, and: 4 time slices.

RR TA time for finished p1 = 50, needed: 10 ms, and: 5 time slices.

RR TA time for finished p3 = 58, needed: 12 ms, and: 6 time slices.

RR Throughput, 3 p, with q: 2, o: 2, is: 0.0517241 p/ms, or 51.7241 p/us

Average RR TA, 3 p, with q: 2, o: 2, is: 50

preemptive RR schedule, quantum = 3 overhead = 0

RR TA time for finished p2 = 23, needed: 8 ms, and: 3 time slices.

RR TA time for finished p1 = 27, needed: 10 ms, and: 4 time slices.

RR TA time for finished p3 = 30, needed: 12 ms, and: 4 time slices.

RR Throughput, 3 p, with q: 3, o: 0, is: 0.1 p/ms, or 100 p/us

Average RR TA, 3 p, with q: 3, o: 0, is: 26.6667

preemptive RR schedule, quantum = 3 overhead = 1

RR TA time for finished p2 = 30, needed: 8 ms, and: 3 time slices.

RR TA time for finished p1 = 36, needed: 10 ms, and: 4 time slices.

RR TA time for finished p3 = 40, needed: 12 ms, and: 4 time slices.

RR Throughput, 3 p, with q: 3, o: 1, is: 0.075 p/ms, or 75 p/us

Average RR TA, 3 p, with q: 3, o: 1, is: 35.3333

preemptive RR schedule, quantum = 4 overhead = 0

RR TA time for finished p2 = 20, needed: 8 ms, and: 2 time slices.

RR TA time for finished p1 = 26, needed: 10 ms, and: 3 time slices.

RR TA time for finished p3 = 30, needed: 12 ms, and: 3 time slices.

RR Throughput, 3 p, with q: 4, o: 0, is: 0.1 p/ms, or 100 p/us

Average RR TA, 3 p, with q: 4, o: 0, is: 25.3333

preemptive RR schedule, quantum = 5 overhead = 0

RR TA time for finished p1 = 20, needed: 10 ms, and: 2 time slices.

RR TA time for finished p2 = 23, needed: 8 ms, and: 2 time slices.

RR TA time for finished p3 = 30, needed: 12 ms, and: 3 time slices.

RR Throughput, 3 p, with q: 5, o: 0, is: 0.1 p/ms, or 100 p/us

Average RR TA, 3 p, with q: 5, o: 0, is: 24.3333

some outputs I have to cut because Chegg say the question is long

Solutions

Expert Solution

a)

import java.util.*;

class FCFS {

    static void findWaitingTime(int processes[], int n,

            int bt[], int wt[]) {

     wt[0] = 0;

for (int i = 1; i < n; i++) {

            wt[i] = bt[i - 1] + wt[i - 1];

        }

    }  

    static void findTurnAroundTime(int processes[], int n,

            int bt[], int wt[], int tat[]) {

         for (int i = 0; i < n; i++) {

            tat[i] = bt[i] + wt[i];

        }

    }

    static void findavgTime(int processes[], int n, int bt[]) {

        int wt[] = new int[n], tat[] = new int[n];

        int total_wt = 0, total_tat = 0;

findWaitingTime(processes, n, bt, wt);

findTurnAroundTime(processes, n, bt, wt, tat);

System.out.printf("Processes Burst time Waiting"

                       +" time Turn around time ");

for (int i = 0; i < n; i++) {

            total_wt = total_wt + wt[i];

            total_tat = total_tat + tat[i];

            System.out.printf(" %d ", (i + 1));

            System.out.printf("     %d ", bt[i]);

            System.out.printf("     %d", wt[i]);

            System.out.printf("     %d ", tat[i]);

        }

        float s = (float)total_wt /(float) n;

        int t = total_tat / n;

        System.out.printf("Average waiting time = %f", s);

        System.out.printf(" ");

        System.out.printf("Average turn around time = %d ", t);

    }

public static void main(String[] args) throws ParseException {

        int processes[] = {1, 2, 3};

        int n = processes.length;

        int burst_time[] = {10, 5, 8};

        findavgTime(processes, n, burst_time);

    }

}

b)

import java.util.*;

class HPF {
   int at, bt, pri, pno;
   Process(int pno, int at, int bt, int pri)
   {
       this.pno = pno;
       this.pri = pri;
       this.at = at;
       this.bt = bt;
   }
}


class GChart {
    int pno, stime, ctime, wtime, ttime;
}

class MyComparator implements Comparator {

   public int compare(Object o1, Object o2)
   {

       Process p1 = (Process)o1;
       Process p2 = (Process)o2;
       if (p1.at < p2.at)
           return (-1);

       else if (p1.at == p2.at && p1.pri > p2.pri)
           return (-1);

       else
           return (1);
   }
}  
class FindGantChart {
   void findGc(LinkedList queue)
   {

       int time = 0;

        TreeSet prique = new TreeSet(new MyComparator());

      
       LinkedList result = new LinkedList();

  
       while (queue.size() > 0)
           prique.add((Process)queue.removeFirst());

       Iterator it = prique.iterator();
       time = ((Process)prique.first()).at;
       while (it.hasNext()) {
           Process obj = (Process)it.next();

           GChart gc1 = new GChart();
           gc1.pno = obj.pno;
           gc1.stime = time;
           time += obj.bt;
           gc1.ctime = time;
           gc1.ttime = gc1.ctime - obj.at;
           gc1.wtime = gc1.ttime - obj.bt;

            result.add(gc1);
       }
       new ResultOutput(result);
   }
}

c)

// Java program for implementation of RR scheduling

import java.util.*;

class RR
{
   static void findWaitingTime(int processes[], int n,
               int bt[], int wt[], int quantum)
   {
       int rem_bt[] = new int[n];
       for (int i = 0 ; i < n ; i++)
           rem_bt[i] = bt[i];
  
       int t = 0; // Current time
while(true)
       {
           boolean done = true;
  
           for (int i = 0 ; i < n; i++)
           {
      if (rem_bt[i] > 0)
               {
                   done = false;
  
                   if (rem_bt[i] > quantum)
                   {
      t += quantum;
  
      rem_bt[i] -= quantum;
                   }
  
      else
                   {
      t = t + rem_bt[i];
  
      wt[i] = t - bt[i];
      rem_bt[i] = 0;
                   }
               }
           }
  
        if (done == true)
           break;
       }
   }
  

   static void findTurnAroundTime(int processes[], int n,
                           int bt[], int wt[], int tat[])
   {
      for (int i = 0; i < n ; i++)
           tat[i] = bt[i] + wt[i];
   }
  
  
   static void findavgTime(int processes[], int n, int bt[],
                                       int quantum)
   {
       int wt[] = new int[n], tat[] = new int[n];
       int total_wt = 0, total_tat = 0;
  

       findWaitingTime(processes, n, bt, wt, quantum);
  
   findTurnAroundTime(processes, n, bt, wt, tat);
  
   System.out.println("Processes " + " Burst time " +
                   " Waiting time " + " Turn around time");
  
   for (int i=0; i<n; i++)
       {
           total_wt = total_wt + wt[i];
           total_tat = total_tat + tat[i];
           System.out.println(" " + (i+1) + "\t\t" + bt[i] +"\t " +
                           wt[i] +"\t\t " + tat[i]);
       }
  
       System.out.println("Average waiting time = " +
                       (float)total_wt / (float)n);
       System.out.println("Average turn around time = " +
                       (float)total_tat / (float)n);
   }
  
   public static void main(String[] args)
   {
   int processes[] = { 1, 2, 3};
       int n = processes.length;
int burst_time[] = {10, 5, 8};
int quantum = 2;
       findavgTime(processes, n, burst_time, quantum);
   }
}


Related Solutions

Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called stringToListOfWords() which takes in a String converts it into a list of words. We assumes that each word in the input string is separated by whitespace.3 2Use the equals() method. 3The split() method of String can split an input up along a provided special string called a regular expression or regex. A regex is much like a code...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called removeAllInstances() which takes in a List and item4 . The method then proceeds to remove each item in the list that matches the given item. For example, if the method is passed the List [1, 4, 5, 6, 5, 5, 2] and the Integer 5, the method removes all 5’s from the List. The List then becomes [1,...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called isPermutaion() which takes in two List objects which contain the same types. It returns true if the Lists are permutations of each other and false if not. Two lists are permutations if they contain the same elements, including the same number of duplicates, but they don’t have to contain the elements in the same order. For example, [1,2,...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method named allMultiples() which takes in a List of integers and an int. The method returns a new List of integers which contains all of the numbers from the input list which are multiples of the given int. For example, if the List is [1, 25, 2, 5, 30, 19, 57, 2, 25] and 5 was provided, the new list...
Create a static method with the appropriate inputs and outputs. Call each of them in the...
Create a static method with the appropriate inputs and outputs. Call each of them in the main method. Write a method called unique() which takes in a List and returns true if all the items in the List are unique. All the items are unique if none of them are the same.Return false otherwise. Please do this in Java.
) Write queries for the following. Include screenshots of the queries and the outputs. Create a...
) Write queries for the following. Include screenshots of the queries and the outputs. Create a procedure named DisplayInfo which takes customer name as a parameter and displays information of that customer. (database – sql_store)
4 Bit Controlled Comparator SPECIFICATIONS: INPUTS:
Create a circuit in Logisim that will take the following...
4 Bit Controlled Comparator SPECIFICATIONS: INPUTS:
Create a circuit in Logisim that will take the following inputs: A : 4 bit binary number B : 4 bit binary number C : Control where: if C = 0, A and B will be treated as unsigned binary if C = 1, A and B will be treated as 2’s complement signed binary (for example, the number 101 represents the value ‘5’ if it is treated as unsigned binary, but it represents...
Using what you know about how to take inputs and make outputs to the console, create...
Using what you know about how to take inputs and make outputs to the console, create a check printing application. Your application will read in from the user an employee's name and salary, and print out a Console Check similar to the following. >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> > | $1,000,000 | > > > > ___Pay to the Order of___ Johnny PayCheck > >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Please only use technique from chapter 1 through 3 in C++ from control structure through object 9th edition
OPERATING SYSTEMS HOMEWORK: PLEASE CODE IN JAVA with comments & POST SCREENSHOTS OF OUTPUTS SCAN This...
OPERATING SYSTEMS HOMEWORK: PLEASE CODE IN JAVA with comments & POST SCREENSHOTS OF OUTPUTS SCAN This algorithm is performed by moving the R/W head back-and-forth to the innermost and outermost track. As it scans the tracks from end to end, it process all the requests found in the direction it is headed. This will ensure that all track requests, whether in the outermost, middle or innermost location, will be traversed by the access arm thereby finding all the requests. This...
Create a detailed process flowchart that includes process inputs, process outputs, activities, activity times, processing and...
Create a detailed process flowchart that includes process inputs, process outputs, activities, activity times, processing and labor requirements for a fictional retail chain of coffee shops. Capacity analysis of the process, including the strategies used to address expected customer demand. Suggested metrics used to measure the process performance. Identify the process problem and make suggestions on how the process can be improved
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT