#include <stdio.h>
#define N 24
typedef struct NODE
{
Char name[10]; /* Job Name */
int proc; Process priority number */
int arritime;//Arrival time
int starttime;//start time
int needtime; /* Process time required */
int RunTime; /* Run time */
int endtime;//End Time
int zztime;//Turnaround Time
float Zznum;
Char state; Status of the process */
/*struct node *next; Chain Pointer */
/*int round; Process time Rotation time slice */
/*int count; Counter */
}JCB;
int main (void) {
JCB Job[n];
int n;
void input ();
Input (job,&n);
void FCFS ();
FCFS (n);
}
void input (JCB job[],int N) {
int tot; Number of jobs
int i;
printf ("Please enter the number of jobs: [2-24]\n");
scanf ("%d", &tot);
for (i=0;i<tot;i++) {
Job[i].proc=i;
printf ("Enter the job name of the [i+1] job, arrival time, time required \ n");
scanf ("%s", &job[i].name);
scanf ("%d", &job[i]. Arritime);
scanf ("%d", &job[i]. Needtime);
scanf ("%d", &job[i]. EndTime);
scanf ("%d", &job[i]. Zztime);
scanf ("%4f", &job[i]. Zznum);
}
printf ("Time required for Job name arrival time \ n");
for (i=0;i<tot;i++)
{
printf ("%s", job[i].name);
printf ("%5d", Job[i]. Arritime);
printf ("%5d", Job[i]. Needtime);
printf ("%5d", Job[i]. EndTime);
printf ("%5d", Job[i]. Zztime);
printf ("%2.1f", Job[i]. Zznum);
}
}
void FCFS (int num)//First come first service algorithm calculation
{
int i,j;
for (i=0;i<num;i++)//sequential execution of jobs entering the queue
{if (i==0)//First process
{
Job[i]. Runtime=job[i]. Needtime;
Job[i]. Endtime=job[i]. Starttime+job[i]. RunTime;
}
Else
{
if (Job[i]. STARTTIME>JOB[I-1]. EndTime)//If there are currently jobs in the execution
{
Job[i]. Runtime=job[i]. Needtime;
Job[i]. Endtimejob[i]. Starttime+job[i]. RunTime;
}
Else
{
Job[i]. Runtime=job[i]. NEEDTIME+JOB[I-1]. Endtime-job[i]. StartTime;
Job[i]. Endtime=job[i]. Starttime+jobc[i]. RunTime;
}
}
(unfinishied)
Experiment two (Job scheduling)