خرید بک لینک

Vote count: 0

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 :

  1. 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 ?!

  2. 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 ?!

asked 4 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 27 فروردين 1395 ساعت: 12:39

صفحه بندی