Re: System Panic Makes My Life Easier
David Colon <[email protected]>
| Newsgroups | gmane.org.user-groups.linux.svlug |
|---|---|
| Message-ID | <CABna1sXvvo7G06ryB7mZ7qtaUBW83U2cjwmKrP=2110YSxgYeA@mail.gmail.com> |
On Thu, Jul 28, 2016 at 5:14 PM, Steve Litt <[email protected]> wrote: > On Thu, 28 Jul 2016 20:58:25 +0000 (UTC) > Daniel Gimpelevich <daniel-R/[email protected]> wrote: > > > On Thu, 28 Jul 2016 13:34:59 -0400, Steve Litt wrote: > > > My prime number generator hits the processor and RAM hard, and also > > > exercises the hard disk. It's pretty easy to compile and run it on a > > > live CD: > > > > > > http://www.troubleshooters.com/codecorn/primenumbers/ > > primenumbers.htm#_Implementation:_Scalability_Through_Paging > > > > > > If you run my prime number generator, watch your processor > > > temperature like a hawk. > > > > It may have hit the processor hard in a desirable way when you wrote > > it, but today, SMP is the norm, and the code above is > > single-threaded, and due to its other resource usage, you can't just > > run multiple instances. > > What if I run four of them, and three of them are piped to /dev/null? You can use taskset to pin a process to a given cpu. Here is a simple example: # ./foo.sh & ./foo.sh & ./foo.sh & ./foo.sh & [1] 28840 [2] 28841 [3] 28842 [4] 28843 [root@ip-172-16-6-116 ~]# taskset -c 0 -p 28840 taskset: failed to execute -p: No such file or directory [root@ip-172-16-6-116 ~]# taskset -p -c 0 28840 pid 28840's current affinity list: 0-15 pid 28840's new affinity list: 0 [root@ip-172-16-6-116 ~]# taskset -p -c 1 28841 pid 28841's current affinity list: 0-15 pid 28841's new affinity list: 1 [root@ip-172-16-6-116 ~]# taskset -p -c 2 28842 pid 28842's current affinity list: 0-15 pid 28842's new affinity list: 2 [root@ip-172-16-6-116 ~]# taskset -p -c 3 28843 pid 28843's current affinity list: 0-15 pid 28843's new affinity list: 3 Using top you can see that the four processes are running on CPUs 0-3: # top -bn1 | grep foo.sh 28840 root 20 0 110m 2972 2776 S 0.0 0.0 0:00.03 0 foo.sh 28841 root 20 0 110m 2928 2728 S 0.0 0.0 0:00.03 1 foo.sh 28842 root 20 0 110m 2956 2760 S 0.0 0.0 0:00.03 2 foo.sh 28843 root 20 0 110m 2932 2736 S 0.0 0.0 0:00.03 3 foo.sh David Colon [email protected] https://tech.dcolon.org _______________________________________________ svlug mailing list [email protected] http://lists.svlug.org/lists/listinfo/svlug