Spring2011.CSCI340Homework4 History

Show minor edits - Show changes to markup

Changed line 2 from:

Due Date: Monday, Apr. 11, 2011\\

to:

Due Date: Wednesday, Apr. 13, 2011\\

Deleted lines 120-121:

NOTE: If a process blocks, it uses only 1 second. If it does not block, it uses the complete quantum.

Added lines 121-122:

NOTE: If a process blocks, it uses only 1 second. If it does not block, it uses the complete quantum.

Deleted lines 130-131:

, based on their time of arrival, and the current simulated time.

Changed line 2 from:

Due Date: Friday, Apr. 8, 2011\\

to:

Due Date: Monday, Apr. 11, 2011\\

Changed line 56 from:

12345 0 5 # seed to the random number generator, the scheduler to use and the time quantum

to:

12345 r 5 # seed the random number generator with 12345, and run the RR scheduler with a 5-sec quantum

Changed lines 123-126 from:

Lastly, you should only read and schedule processes from the input file 1 line at a time. That is, once your code has read the first process from input, don't read in the next process until the current process is ready to be scheduled (i.e. it's arrival time = current time).

Feel free to modularize your design using meaningful functions.

to:

Lastly, you have two options on how to handle arriving processes:

  1. Either read and schedule processes from the input file one line at a time. That is, once your code has read the first process from the input, do not read in the next process until the current process is ready to be scheduled (i.e., its arrival time <= current time).
  2. Or, read all the processes from the input file and place them in a temporary queue (ordered by time of arrival). Move processes from the temporary to the ready queue when they are ready to be scheduled (i.e., their arrival time <= current time).

, based on their time of arrival, and the current simulated time.

Modularize your design using meaningfully named functions.

Changed lines 141-142 from:
  • Priority Scheduling: The priority for each process will be defined as @1/f@, where @f@ is the fraction of the previous quantum used by that process. For example, assuming a time quantum of @50@, if a process runs for @25@ time units, then its fraction of used time is @25/50 = 1/2@. Hence, the priority of that process becomes @1/(1/2) = 2@
to:
  • Priority Scheduling: The priority for each process will be defined as @1/f@, where @f@ is the fraction of the previous quantum used by that process. For example, assuming a time quantum of @50@, if a process runs for @25@ time units, then its fraction of used time is @25/50 = 1/2@. Hence, the priority of that process becomes @1/(1/2) = 2@ (Note: You should initialize all incoming processes to the highest possible priority, so that every process will run at least once initially.)
Changed lines 28-30 from:
   // argc equals the number of arguments received
   // argv is an array containing all command line arguments
   // argv[0] is set to the name of the program
to:
   /* argc equals the number of arguments received
      argv is an array containing all command line arguments
      argv[0] is set to the name of the program */
Changed line 77 from:
   struct PBR *next;          // a pointer to the next PBR in the queue (i.e. linked list)
to:
   struct PBR *next;          /* a pointer to the next PBR in the queue (i.e. linked list) */
Changed line 108 from:

// map random range to 0 through 99

to:

/* map random range to 0 through 99 */

Changed line 111 from:

// assuming an IO chance of 30%

to:

/* assuming an IO chance of 30% */

Changed line 113 from:
   // process blocks and is rescheduled 
to:
   /*  process blocks and is rescheduled */
Changed lines 115-118 from:
   // process keeps running

// time is advanced by 1 // ...

to:
   /*  process keeps running */

/* time is advanced by 1 */ /* ... */

Added lines 7-8:

NOTE: This homework is an extension of homework 3. Verbiage from homework 3 is included here to make this assignment self-contained. The extension involves adding two more scheduling algorithms (Priority and Round Robin). It also slightly changes the format of the input data.

Changed lines 56-58 from:

12345 0 5 # seed to the random number generator, the scheduler to use and the time quantum 0 1 4 30 # first process has ID=0, arrives at second 1, will execute in 4 seconds and has a 30 percent chance to block for IO 1 3 2 5 # ...

to:

12345 0 5 # seed to the random number generator, the scheduler to use and the time quantum 0 1 4 30 # process ID is 0, arrives at sec 1, will execute in 4 secs, has 30% chance to block for IO 1 3 2 5 # ...

Changed lines 37-41 from:
  • The first value will be used as a seed to the random number generator srand() (so results can be reproduced);
  • the second value will define which scheduling algorithm should be used (FCFS = 'f', Priority = 'p', RR = 'r'); and
to:
  • The first value will be used as a seed to the random number generator srand() (so results can be reproduced),
  • the second value will define which scheduling algorithm should be used (FCFS = 'f', Priority = 'p', RR = 'r'), and
Changed lines 43-44 from:

On each additional line, the input file will contain 4 integers describing a single process to be run. The first integer is the process ID, the second integer is the arrival time of the process, the third integer is the required execution time of the process (remember, we are simulating execution), and the forth integer is the probability the process will block for IO.

to:

On each additional line, the input file will contain 4 integers describing a single process to be run:

  • The first integer is the process ID,
  • the second integer is the arrival time of the process,
  • the third integer is the required execution time of the process (remember, we are simulating execution), and
  • the forth integer is the probability the process will block for IO.
Changed lines 36-39 from:

The first line of the input file will contain 1 integer, 1 character, and 1 integer values. The first value will be used as a seed to the random number generator srand() (so results can be reproduced), the second value will define which scheduling algorithm should be used (FCFS = 'f', Priority = 'p', RR = 'r') and the third will be the quantum/slice value to use for the preemptive algorithms.

You may assume that the first and second values are separated by a single space character only.

to:

The first line of the input file will contain 1 integer, 1 character, and 1 integer values:

  • The first value will be used as a seed to the random number generator srand() (so results can be reproduced);
  • the second value will define which scheduling algorithm should be used (FCFS = 'f', Priority = 'p', RR = 'r'); and
  • the third will be the quantum (time-slice) value to use for the preemptive algorithms.

You may assume that the first and second values are separated by a single space character.

Changed lines 36-37 from:

The first line of the input file will contain 1 integer, 1 character, and 1 integer values. The first value will be used as a seed to the random number generator @srand()@ (so results can be reproduced), the second value will define which scheduling algorithm should be used (FCFS = 'f', Priority = 'p', RR = 'r') and the third will be the quantum/slice value to use for the preemptive algorithms.

to:

The first line of the input file will contain 1 integer, 1 character, and 1 integer values. The first value will be used as a seed to the random number generator srand() (so results can be reproduced), the second value will define which scheduling algorithm should be used (FCFS = 'f', Priority = 'p', RR = 'r') and the third will be the quantum/slice value to use for the preemptive algorithms.

Added lines 1-213: