요상합니다.. 조언 부탁드립니다.
typedef struct Process{
char p_id[128];
int arrival;
int service;
int remain;
int finish;
char *stmt;
struct Process *next;
struct Process *link;
}Process;
typedef struct History{
Process *proc;
int start; /* end - start = service*/
int end; /* turn - service = wait */
int finish; /* finish - arrive = turn */
}History;
History *history[MAX];
void printhistory(){
int i;
int service;
int wait;
int turn;
Process *p;
printf("* Calculated scheduling parameters : Using %s\n\n", policy_s);
for(i=0; i
service = history[i]->end - history[i]->start;
turn = proclist[i]->finish - proclist[i]->arrival;
wait = turn - service;
printf("%s: arr=%d\t| run %d-%d\t| service = %d\t| wait = %d\t| ",
proclist[i]->p_id, proclist[i]->arrival,
history[i]->start, history[i]->end,
service, wait);
if(history[i]->finish > 0)
printf("turn = %d\n", turn);
else
printf("\n");
}
printf("\nAverage turnaround time = %f\n", 1.0);
printf("Average waiting time = %f\n", 1.0);
}
실행중에 한번 결정되면 절대 다시 변경되지 않는 문자열이 바뀝니다.
예를 들어
p1 : +
p2 : +
p3 : -+
p4 : --+
p5 : ---+
p6 : +
p7 : +
p8 : +
p9 : ------+
p10: ---+
CPU time 32
* Calculated scheduling parameters : Using SJF
p2: arr=0 | run 1-2 | service = 1 | wait = 1 | turn = 2
p3: arr=1 | run 2-4 | service = 2 | wait = 1 | turn = 3
p4: arr=2 | run 4-7 | service = 3 | wait = 2 | turn = 5
p8: arr=5 | run 7-8 | service = 1 | wait = 2 | turn = 3
p7: arr=7 | run 8-9 | service = 1 | wait = 1 | turn = 2
p1: arr=14 | run 15-16 | service = 1 | wait = 1 | turn = 2
p5: arr=14 | run 16-20 | service = 4 | wait = 2 | turn = 6
p6: arr=15 | run 20-21 | service = 1 | wait = 5 | turn = 6
p9: arr=20 | run 21-28 | service = 7 | wait = 1 | turn = 8
+: arr=21 | run 28-32 | service = 4 | wait = 7 | turn = 11
이라는 출력 결과가 있을때 제일 마지막 줄 "p10"이 들어가야 할 자리에 "+"으로 문자열이 바뀝니다.
똑같은 소스인데 visual studio에서는 정상적으로 동작하고 linux gcc-4.4.3에서는 Segmentation fault가 납니다..(위의 실행 결과는 좀 억지로 나오게 한겁니다.)
첨부 | 파일 크기 |
---|---|
![]() | 2.94 KB |
음 ..
- newProc->stmt = (char *) malloc(sizeof(LENGTH));
+ newProc->stmt = (char *) malloc(LENGTH);
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
되면 한다! / feel no sorrow, feel no pain, feel no hurt, there's nothing gained.. only love will then remain.. 『 Mizz 』
어잌후....
아무래도 안경은 바꿔야겠네요 ㅠㅠ
감사드립니다.
댓글 달기