0

I need for a specific reason of my work to configure a process in Ubuntu 14.10 Linux distro to use alternately different CPUs.

I know with taskset I can pin a process on a specified CPUs but how I tell that process to use let say 50% of CPU 0 and 50% of CPU 1.

UPDATE

The process I'm runing is single threaded, maybe I'm wrong to try to tell a single threaded process to use two CPUs with roundrobin algorithm.

Thank you for your insights and helps.

Regards.

user2567806
  • 460
  • 3
  • 7
  • 17
  • single thread = single cpu :( – sstan Aug 11 '15 at 01:24
  • So @sstan you mean I'm wrong and there is no rationality there ? ;) – user2567806 Aug 11 '15 at 01:33
  • 1
    Maybe I'm misunderstanding your question. If you are trying to split a thread so that it ***concurrently*** executes the work on 2+ CPU cores, that is not possible. But if you are asking about having a single thread switch back and forth between CPU cores, then I don't know how to do that, but it must not be impossible. But it probably wouldn't be desirable, as you would lose the benefit from CPU caching and things like that. Better to let the OS decide the best way to schedule a thread. – sstan Aug 11 '15 at 01:50
  • @sstan "But if you are asking about having a single thread switch back and forth between CPU cores" Yep ! thank you. I need to do that but it seems irrational. – user2567806 Aug 11 '15 at 02:23
  • Related: http://serverfault.com/questions/411665/single-threaded-application-being-balanced-across-cpu-cores – sstan Aug 11 '15 at 02:26
  • thanks but id does not answer my issue :(, anyway I will bypass this issue. – user2567806 Aug 11 '15 at 02:31
  • A context switch MIGHT kick a process off one cpu and execute on a different cpu when it's switchs back in. – Isaiah van der Elst Aug 25 '15 at 23:51

1 Answers1

0

I would use task set to pin two processes to the two different cores, then use a message passing protocol to switch the processing from one core to the other and back again. I'm assuming you don't want to concurrently execute a task across two cores.

Taylor Kidd
  • 1,463
  • 1
  • 9
  • 11
  • It may work but I do not want to use message passing here in my case. I used multiple instances of the process and I pinned them on different cpus, so it worked. Thanks guys. – user2567806 Aug 28 '15 at 04:17