From: trin0008@ermine.ox.ac.uk (Rick Heylen)
Subject: Proper multiprocessor multithreading
Date: 1997/03/31 [thread overview]
Message-ID: <5hp12d$ntc@news.ox.ac.uk> (raw)
The following program is an attempt to demonstrate proper multiprocessor
multiprocessing on a multiprocessor Alpha.
#include <pthread.h>
#include <stdio.h>
pthread_t threads[4];
void *spin(int p){
int i;
for(i=0;i<10000000;i++)
{if (i % 1000000==0) printf("Bing%d\n",p);fflush(stdout);}
}
main() {
int i;
for (i=0;i<4;i++) pthread_create(&threads[i],NULL,spin,i);
sleep(1000);
}
You compile this with -pthread
I can't get it to use more than 1 CPU's worth of cpu utilisation as shown
by
erm0>ps -m -Opsr,pcpu
PID PSR %CPU S TTY TIME COMMAND
10472 3 98.1 R pts/14 0:36.86 a.out
3 0.0 I 0:00.02
0 0.0 I 0:00.00
0 0.0 I 0:00.01
3 45.9 R 0:10.82
3 48.1 R 0:10.16
1 2.1 R 0:08.20
2 2.0 R N 0:07.65
However, proper kernel multithreading is possible as I have seen a
dxmandel process with a total pcpu over 300% by running four threads over
four processors.
Why is my program not using all the available processors?
Rick
--
--
All I could see was the B-side of the disc which had assumed an oval shape
with the label on the outside rim.
PGP key 512/CA5CADED Differential Cryptanalyst and C/C++, Java Programmer
reply other threads:[~1997-03-31 5:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox