Spring2012.CSCI340Homework2 History

Hide minor edits - Show changes to markup

Deleted line 84:
Deleted line 95:
Deleted line 96:
Added lines 107-123:

So, for the above input example, the output should be:

(:source lang=c tabwidth=3 -trim:) Process 0 was allocated the CPU at time 1 seconds. Process 0 completed at time 5 seconds. Process 1 was allocated the CPU at time 5 seconds. Process 1 completed at time 7 seconds. Process 2 was allocated the CPU at time 7 seconds. Process 2 completed at time 14 seconds.

Simulation Statistics:

Average wait time: 1.0000 seconds Average turnaround time: 5.3333 seconds Average execution time: 4.3333 seconds (:sourcend:)

Changed line 45 from:

0 1 4 # first process has ID=0, arrives at second 1, and requires 4 seconds of CPU time to finish

to:

0 1 4 # first process has ID=0, arrives at second 1, and needs 4 secs of CPU time

Changed line 45 from:

0 1 4 # first process has ID=0, arrives at second 1, and will execute in 4 seconds

to:

0 1 4 # first process has ID=0, arrives at second 1, and requires 4 seconds of CPU time to finish

Changed line 2 from:

Due Date: Friday, Feb. 17, 2012\\

to:

Due Date: Monday, Feb. 20, 2012\\

Added lines 163-166:

or as follows (if you include a C header file):

% submit csci340 hmwk2 fcfs.c fcfs.h

Changed line 2 from:

Due Date: Monday, Feb. 20, 2012\\

to:

Due Date: Friday, Feb. 17, 2012\\

Deleted lines 11-13:
  • To gain experience using C file I/O, linked lists
  • To gain experience with process management
Changed lines 40-42 from:

Each line of the input file will contain 3 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, and the third integer is the required execution time of the process (remember, we are simulating execution). You should ignore anything past the third integer on each line (e.g., we may use this feature to implement input-file comments). The file may contain an arbitrary number of processes.

to:

The first line of the input file contains the number of processes that will be used in the simulation.

Each subsequent line of the input file will contain 3 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, and the third integer is the required execution time of the process (remember, we are simulating execution). You should ignore anything past the third integer on each line (e.g., we may use this feature to implement input-file comments). The file may contain an arbitrary number of processes.

Added line 47:

3 # number of processes to schedule

Changed lines 58-59 from:

queue in order of their arrival time. The PBRs should be represented as C structs, and the queue as a linked list.

to:

queue in order of their arrival time. The PBRs should be represented as C structs, and the queue as a dynamic array.

Deleted line 65:
   struct PBR *next;          // a pointer to the next PBR in the queue (i.e. linked list)
Deleted lines 67-80:

To allocate space for the C structs use malloc(). For example:

(:source lang=c tabwidth=3 -trim:) struct PBR *head = (struct PBR *)malloc(sizeof(struct PBR)); (:sourcend:)

To deallocate the space use free(). For example:

(:source lang=c tabwidth=3 -trim:) free(head); (:sourcend:)

Your program should deallocate all the space it allocated. A good strategy is to deallocate the PBR of any process that has completed. Also, depending on how you implement your linked list, you may also use a function called cleanUp(), which takes as argument(s) the program's dynamic data structure(s). It should be called before the program exits.

Changed line 102 from:

Process n completed at q seconds.

to:

Process n completed at time q seconds.

Changed line 100 from:

Process n was allocated the CPU at p seconds.

to:

Process n was allocated the CPU at time p seconds.

Added lines 1-190: