The following is the simple c source code , which char x[2048] is global var and func1 is called by thread1 , func2 is called by thread2 :
char x[2048]={0} , y[16]={0};
void func1(){
strcpy(x,y);
}
void func2(){
printf("(%s)n",x);
}
int main(int argc, char **argv){
stcpy(y,argv[1],sizeof(y)-1);
}
In Intel's cpu , one cache line has 64 bytes in it , so x should occupy 32 cache lines , my question are :
-
while thread1 call func1 , should all 32 cache lines avaliable to that cpu cache until then do strcpy ?! or compiler knowes just one cache line is enough to do the job ?!
-
While thread2 call func2 , should all 32 cache lines avaliable to that cpu cache until then do printf ?! or compiler can identify one cache line is enough ?!
