Find the answer to your Linux question:
Results 1 to 3 of 3
With all those Mutli-Core-CPU and Multi-CPU hardware popping up everywhere I really wonder if and how one can define that one process has to use a defined Core/CPU. The reason ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2007
    Posts
    11

    Move process to CPU/Core?


    With all those Mutli-Core-CPU and Multi-CPU hardware popping up everywhere I really wonder if and how one can define that one process has to use a defined Core/CPU.

    The reason I ask is because I wonder if it would be possible to make a separation of CPU-insensitive processes and applications I want to use right now.
    I know there is the Linux scheduler that does a pretty good job with that, but it would be pretty cool if one can control this in some way.

    Sorry if this should be in another forum, but I thought it is mostly kernel-related, isn't it?

    Werner

    PS: I do not yet have the hardware to test this yet - I'm just curious

  2. #2
    Linux Newbie
    Join Date
    Mar 2008
    Location
    Hyderabad
    Posts
    109
    Each process has cpu_affinity which is a mask of the CPUs on which the process is allowed to run.
    If you wish to run your process on a particular CPU all you have to do is just set the cpu_affinity of the process.

  3. #3
    Just Joined!
    Join Date
    Jan 2007
    Posts
    11
    Ohhh, many thanks for that info digvijay.gahlot.

    Just for the curious, there are some nice command line tools like taskset for that:
    "taskset - retrieve or set a processes's CPU affinity Linux Man Page"

    Something like this (untested) should work fine:
    Code:
    taskset  -c1,2 <command>	# Start a process and limit it to 2. and 3. CPU.
    
    taskset  -c1,2 -p<pid>	# Change affinity of existing process to only run on 2. and 3. CPU
    Werner

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •