Usenet comp.unix.osf.osf1 (1992-2004)
 help / color / mirror / Atom feed
* Proper multiprocessor multithreading
@ 1997-03-31  5:00 Rick Heylen
  0 siblings, 0 replies; only message in thread
From: Rick Heylen @ 1997-03-31  5:00 UTC (permalink / 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



^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1997-03-31  5:00 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
1997-03-31  5:00 Proper multiprocessor multithreading Rick Heylen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox