LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-28-2010, 08:22 AM   #1
grubby23
LQ Newbie
 
Registered: Jan 2010
Posts: 1

Rep: Reputation: 0
Setting Processor Affinity in application


Hi,

Let us assume I have a very simple program.I wonder if there is any
possibility that I can set in this application an affinity so that
the processor binds it to core 2 for instance.

Code:
int main(int argc, char *argv[]){
        int j

        // SET_AFFINITY(CORE 2) ... IS THIS POSSIBLE here?
        for(j = 0; j < 10; j++)

        {

          printf('test\n');
        }  
}
Is this possible to do in an application that runs than under root? Or
is this just possible after the application started with using the taskset tool?

many thanks
 
Old 01-28-2010, 10:40 AM   #2
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
Assuming you're using Linux, take a look to sched_setaffinity
 
  


Reply



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
Processor Affinity vikesh.u Linux - Kernel 1 09-07-2009 12:52 PM
Setting thread affinity lennyk Programming 1 02-17-2009 01:56 AM
How do I manage CPU affinity FBO multiple instances of an application in RHEL v5.x? Kevin McLeod Linux - Newbie 2 02-05-2009 05:40 PM
Can you set processor affinity on Linux? Thaidog Linux - General 1 02-27-2008 09:31 AM
Processor affinity and cpu scheduling...? Thaidog Linux - Newbie 5 01-09-2003 07:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:20 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
Open Source Consulting | Domain Registration