LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   C programing (https://www.linuxquestions.org/questions/linux-newbie-8/c-programing-4175587597/)

khizar35 08-22-2016 12:54 AM

C programing
 
I have a code that makes threads all i want is to allocate threads to different cores...how would i do this..my code is

void * thread1()
{

for(int b=0; b<20; b++){
printf("Hello!!\n");
}
}

void * thread2()
{
for(int a=0; a<20; a++){
printf("How are you?\n");
}
}

int main()
{
int status;
pthread_t tid1,tid2;

pthread_create(&tid1,NULL,thread1,NULL);
pthread_create(&tid2,NULL,thread2,NULL);
pthread_join(tid1,NULL);
pthread_join(tid2,NULL);
return 0;
}

pan64 08-22-2016 01:00 AM

probably this helps a bit:
http://programmers.stackexchange.com...ore-processors

khizar35 08-22-2016 01:11 AM

i am not good at programming..but i heard Sched_affinity function can do this...but i really dont know how to use it in my program

pan64 08-22-2016 01:21 AM

http://stackoverflow.com/questions/1...give-code-samp


All times are GMT -5. The time now is 08:18 PM.