代写代考 CSE3221 “scheduler” project

* Description: Some helper functions to be used for CSE3221 “scheduler” project

/* Some hints to use these helper functions in this project */
Step 1: You should include the header file in your main scheduler code:

Copyright By PowCoder代写 加微信 powcoder

#include “sch-helpers.h”

Step 2: you should declare a global array in your own fcfs.c to hold info for all processes:

process processes[MAX_PROCESSES+1]; // a large structure array to hold all processes read from data file
int numberOfProcesses=0; // total number of processes

Step 3: you can call function readProcess() to read all data from stdio and sort the processes array ascending by arrival time:

while (status=readProcess(&processes[numberOfProcesses])) {
if(status==1) numberOfProcesses ++;
} // it reads pid, arrival_time, bursts to one element of the above struct array
qsort(processes, numberOfProcesses, sizeof(process), compareByArrival);

Step 4: You may consider to use the following linked-list based Queue management functions to impelement all scheduling queues (Ready Q and Device Q) for your scheduler:

process_node *createProcessNode(process *);
void initializeProcessQueue(process_queue *);
void enqueueProcess(process_queue *, process *);
void dequeueProcess(process_queue *);

Step 5: After you are done, you can submit your fcfs.c as well as sch-helpers.h sch-helpers.c to the system.
Your code should compile as:

$$ gcc -o fcfs fcfs.c sch-helpers.c

In this case you can redirect all CPU load data to stdio when you run your FCFS schedule:

$$ fcfs < CPULoad.dat OR $$ cat CPULoad.dat | fcfs #include
#include
#include
#include
#include
#include “sch-helpers.h” /* include a header file for function defintions and others */

/** Error management functions **/

/* print error message to stderr and terminate abnormally */
void error(char *msg) {
fprintf(stderr, “%s\n”, msg);

/* print error message displaying the first errant line in the input,
or a special message in the presence of unprintable characters,
and terminate abnormally. */
void error_malformed_input_line(char *line) {

/* handle lines with unprintable characters */
for (i=0;iCS代考 加微信: powcoder QQ: 1823890830 Email: powcoder@163.com