LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 08-22-2016, 01:54 AM   #1
khizar35
LQ Newbie
 
Registered: Aug 2016
Posts: 2

Rep: Reputation: Disabled
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;
}
 
Old 08-22-2016, 02:00 AM   #2
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,574

Rep: Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339Reputation: 4339
probably this helps a bit:
http://programmers.stackexchange.com...ore-processors
 
Old 08-22-2016, 02:11 AM   #3
khizar35
LQ Newbie
 
Registered: Aug 2016
Posts: 2

Original Poster
Rep: Reputation: Disabled
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
 
Old 08-22-2016, 02:21 AM   #4
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 13,574

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


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
c programing next? a22an Linux - Embedded & Single-board computer 7 10-13-2015 08:51 AM
programing Priya_13 Linux - Newbie 2 07-09-2013 07:25 AM
C programing Eirik Linux - Software 2 01-23-2011 11:48 AM
c programing in rhel5?? koushik08oct Linux - Newbie 5 12-06-2009 06:25 PM
How do C++ programing rahilmaknojia Programming 12 08-07-2008 09:25 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:16 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration