Question

I would like to know how multiprocessing works.

Does this mean I can run 8 separate process simultaneously, if I have 8 core CPU ?

For example here is my processor information.

giri@ubuntu:~$ lscpu
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                1
On-line CPU(s) list:   0
Thread(s) per core:    1
Core(s) per socket:    1
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 42
Stepping:              7
CPU MHz:               2294.762
BogoMIPS:              4589.52
Virtualization:        VT-x
L1d cache:             32K
L1i cache:             32K
L2 cache:              256K
L3 cache:              3072K
NUMA node0 CPU(s):     0

Here is my cpuinfo

giri@ubuntu:~$ cat /proc/cpuinfo
processor   : 0
vendor_id   : GenuineIntel
cpu family  : 6
model       : 42
model name  : Intel(R) Core(TM) i3-2350M CPU @ 2.30GHz
stepping    : 7
microcode   : 0x23
cpu MHz     : 2294.762
cache size  : 3072 KB
physical id : 0
siblings    : 1
core id     : 0
cpu cores   : 1
apicid      : 0
initial apicid  : 0
fpu     : yes
fpu_exception   : yes
cpuid level : 13
wp      : yes
flags       : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer xsave avx lahf_lm arat epb xsaveopt pln pts dtherm tpr_shadow vnmi flexpriority ept vpid
bogomips    : 4589.52
clflush size    : 64
cache_alignment : 64
address sizes   : 36 bits physical, 48 bits virtual
power management:

As you can see, my number of CPU(s) is 1.

Does this mean multiprocessing is useless in my situation?

Was it helpful?

Solution

You can run N thread simultaneously if you have N cores (if threads per core = 1). Though if you try to run more threads than you have processors, the operating system will run your threads one after the other by small 'slices' and they will seem to run in parallel.
So multi threading will not allow your code to be faster in this case, but it's often interesting, you can for instance have a thread waiting for the disk to reply while another waits for the network and a third one runs...
i3-2350M should be 2 cores / 2 threads per core, so 4 threads running at the same time.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top