请看这段代码:
int page;
int stop = FALSE;
while (!stop) {
printf("stop0 %i\n", stop);
if (physmem[fifo_index % opts.phys_pages] == NULL) {
stop = TRUE;
page = fifo_index % opts.phys_pages;
printf("stop1 %i\n", stop);
} else if (physmem[fifo_index % opts.phys_pages]->gc_bit == 0) {
physmem[fifo_index % opts.phys_pages]->gc_bit = 1;
printf("stop2 %i\n", stop);
} else if (physmem[fifo_index % opts.phys_pages]->gc_bit == 1) {
stop = TRUE;
page = fifo_index % opts.phys_pages;
printf("stop3 %i\n", stop);
}
printf("sto4 %i\n", stop);
fifo_index++;
printf("stop5 %i\n", stop);
}
输出结果为:
stop0 0
stop1 1
stop4 1
stop5 1
stop0 0 '<<< I dont understand this part'
stop1 1
stop4 1
stop5 1
'<<<< The code exits here!! In the second loop...whyy??'
答案 0 :(得分:0)
您可以将printf
置于while
语句之上,并检查您是否进入了两次循环。