I'm writing a cache simulator, and for some reason, my if statements keep giving me segfaults. For debugging purposes, I've added some print statements. Everything prints exactly the way I expect it to, up until just before the if statement, and then it just spits back "Segmentation Fault"/
int find_set(node** cache, unsigned set_i, long t, int E){
printf("finding set\n");
int i; //index
int val;
for (i = 0; i < E; i++){
printf("trying seti = %d and i = %d \n",set_i,i);
printf("cache[set_i][i]->valid_bit = %d\n",cache[set_i][i]->valid_bit);
printf("cache[set_i][i]->tag = %d\n",cache[set_i][i]->tag);
if (cache[set_i][i]->valid_bit == 1) &&
((cache[set_i][i]->tag) == t){
printf("found tag! \n");
cache[set_i][i]->LRU_count = 0; //just used
return i; //index of the set we found
}
}
}
return -1; //not found
}
and it spits back "Segmentation Fault" when I try to run it. I'm out of ideas. Help?
Aucun commentaire:
Enregistrer un commentaire