init(int argc, char *argv[]) { int i,j,p; if (argc != 5) { fprintf (stderr, "Insufficient number of arguments\n"); fprintf (stderr, "Usage : %s <parts_file> <job_sequence_file> <machine_file> <jobs_file>\n", argv[0]); exit(-1); } /*BUG this should come as third what if part definitions are more but less parts are requested */ if (read_parts_file(argv[1])) { fprintf (stderr, "Error reading parts file %s\n", argv[1]); exit(-1); } if (read_jobs_file(argv[4])) { fprintf (stderr, "Error reading jobs file %s\n", argv[2]); exit(-1); } if (read_part_jobs_file(argv[2])) { fprintf (stderr, "Error reading part jobs file %s\n", argv[3]); exit(-1); } if (read_machines_file(argv[3])) { fprintf (stderr, "Error reading machines file %s\n", argv[4]); exit(-1); } for(i=0;i<total_parts;i++) remaining_parts += parts[i].count; runq=(struct readyjob *) malloc(remaining_parts * sizeof(struct readyjob)); for(p = i= 0; i < total_parts; i++) { for(j = 0; j < parts[i].count; j++) { runq[p].partid = i; runq[p].partsrno = PART_SLNO_START + j; runq[p].partidx = 0; runq[p].jid = parts[i].jobs[0]; runq[p].starttime = runq[p].priority=0; runq[p].rtime = jobs[parts[i].jobs[0]].rtime; runq[p].priority_incby = -1; p++; } } chart = (struct schedule_chart **) malloc (total_machines * sizeof(struct schedule_chart *)); for(i = 0; i < total_machines; i++) chart[i] = (struct schedule_chart *) malloc (alloc_time * sizeof(struct schedule_chart)); return 0; }
Parts load_parts(char *infile) { return read_parts_file(infile, read_to_db); }