Public bug reported:

Multithreading simply is not working on my computer, as it is not only
using only one processor, the threads are not switching. One completes
and then another completes, even though the two are independent and take
20 seconds of cpu time each.

The code is here: http://en.wikipedia.org/wiki/Pthreads
I compiled with these options:  g++ multicore.c -D_POSIX_PTHREAD_SEMANTICS 
-lpthread -pthread -o multicore
 ( I saved the code as multicore.c )

And this command: /usr/bin/time -v ./multicore

got this response:


a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
a
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
  b
        Command being timed: "./multicore"
        User time (seconds): 11.34
        System time (seconds): 0.07
        Percent of CPU this job got: 70%
        Elapsed (wall clock) time (h:mm:ss or m:ss): 0:16.30
        Average shared text size (kbytes): 0
        Average unshared data size (kbytes): 0
        Average stack size (kbytes): 0
        Average total size (kbytes): 0
        Maximum resident set size (kbytes): 0
        Average resident set size (kbytes): 0
        Major (requiring I/O) page faults: 0
        Minor (reclaiming a frame) page faults: 287
        Voluntary context switches: 1
        Involuntary context switches: 3737
        Swaps: 0
        File system inputs: 0
        File system outputs: 0
        Socket messages sent: 0
        Socket messages received: 0
        Signals delivered: 0
        Page size (bytes): 4096
        Exit status: 0


The a's and b's should be mixed evenly throughout the stream. They obviously 
are not.

This is en excerpt from top, running while "multicore" is running.
 Cpu0  :100.0%us,  0.0%sy,  0.0%ni,  0.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st
 Cpu1  :  0.0%us,  0.0%sy,  0.0%ni,100.0%id,  0.0%wa,  0.0%hi,  0.0%si,  0.0%st

As it shows, even though the is cpu-bound multi-threaded work to be
done, the second core is not being utilized at all.

To prove I have two processors, this command: grep processor /proc/cpuinfo
gives this:
processor       : 0
processor       : 1

But it must be possible because ffmpeg is reported as such in top:

  PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
 7018 sean      15   0  309m 236m 1684 R  120 11.7  26:15.29 ffmpeg

CPU% is greater than 100

I'm using a stock ubuntu kernel:
uname -a:
Linux bar 2.6.20-16-generic #2 SMP Thu Jun 7 20:19:32 UTC 2007 i686 GNU/Linux

** Affects: ubuntu
     Importance: Undecided
         Status: New

-- 
Multithreading not utilizing both cores
https://bugs.launchpad.net/bugs/139631
You received this bug notification because you are a member of Ubuntu
Bugs, which is the bug contact for Ubuntu.

-- 
ubuntu-bugs mailing list
ubuntu-bugs@lists.ubuntu.com
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to