# SMP Management

## xqz

Hello,

I was wondering if there is anyway to easily manage dual core processor, allow programs to 1 cpu and another to the other processor? thanks

----------

## ejmiddleton

This is generally handled by the operating system (and will probably do a better job of allocating resources) but it is possiable.  Take a look at the article on http://www.linuxjournal.com/article/6799  It has a command line tool for setting process affinity.

----------

## lightsout

Under RHEL there is a command called "taskset" which allows you to bind processes to specific CPU cores. So this can do what you want, it just does't appear available under Gentoo.

May wish to google for taskset, see if you can find some more information it.

----------

## ejmiddleton

method 1

```
# emerge sys-process/schedtool
```

to set a process to run on CPU1

```
# schedtool -a 1 <pid>
```

to run a program to run on CPU1

```
# schedtool -a 1 -e <program>
```

method 2

```
# emerge sys-process/schedutils
```

to set a process to run on CPU1

```
# taskset -p 0x00000002 <pid>
```

to run a program to run on CPU1

```
# taskset 0x00000002 -- <program>
```

----------

## xqz

Thanks, much appreciated

----------

## bitwise

why would you want to?

----------

## HackingM2

 *Saburo wrote:*   

> why would you want to?

 

Lots of reasons.  

As an example I use Asterisk PBX software and Digium TDM interfaces which require very low latency.  I have a multi processor system (2 x Pentium Pro 200) which, under normal circumstances, is far too slow to be usable for Asterisk.  This is manifested by lots of clicking and dropouts on the line.

Closer examination of the problem revealed IRQ latency to be the problem.  By setting the CPU affinity of all IRQs and processes to CPU0, and setting the CPU affinity for Asterisk and its driver to CPU1 the problems can be completely solved.  

I can now hit the server as hard as I like and Asterisk just keep sailing along as if it is on its own server, which in some ways it is.    :Smile:   In fact in some ways it is better than being on its own server as all the IRQs for disk/net access, etc. and processes for logging and TCP/IP, etc. are handled by a different CPU.

----------

## nephros

Very clever setup. Thanks for sharing  :Wink: 

----------

## DaysSinceTheDoor

HackingM2,

We do this for the same exact reason... accept we are handling a much higher call volume. In order to squeeze every last possible call out of the system we loaded a stripped down gentoo install (no portage, gcc, etc) into ram using a modified initrd and ran that. Works great. The best part about doing it this way is that we have the linuxrc script of the initrd call schedtool and it executes init on the first core (we have four) so that the whole system is on a single core and we move asterisk and the zaptel driver to the other 3 once the system is up and running. Sound quality is amazing and we are recording both sides of every single phone call, using sox to merge them into one stereo wav file with the caller and the callie on their own channel, and compressing them with lame.

----------

