요상합니다.. 조언 부탁드립니다.

gopass2002의 이미지

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가 납니다..(위의 실행 결과는 좀 억지로 나오게 한겁니다.)

File attachments: 
첨부파일 크기
Package icon TestC (2).zip2.94 KB
ymir의 이미지

- 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 』

gopass2002의 이미지

아무래도 안경은 바꿔야겠네요 ㅠㅠ

감사드립니다.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.