Date: Mon, 1 Sep 2003 03:13:31 +0100 (BST) From: =?iso-8859-1?q?RMH?= <rmhlldr@yahoo.co.uk> To: current@freebsd.org Subject: threading problems Message-ID: <20030901021331.82307.qmail@web21502.mail.yahoo.com>
index | next in thread | raw e-mail
[-- Attachment #1 --]
Hello gentlemen,
I seem to have threading problems with 5.1-RELEASE. Every time I run
a multithreaded application (linked against libc_r) on a SMP system,
I get only 1 CPU loaded at any moment given. I tried different
software, including Viewperf, but results remain the same. When linked
against Linuxthreads, some applications work excellent, some segfault.
Here is some kind of a simple multithreaded program for a 2-way SMP
system that writes zeros to a memory array as fast as possible; it
runs fine with Linuxthreads or directly under Linux.
# gcc -O2 -fomit-frame-pointer -march=i686 -o smp smp.c -pthread
# ./smp
4Gb per pass mode
INTEGER | WRITING 8 Kb block: 1351 Mb/s
res0: 674
res1: 677
# gcc -O2 -fomit-frame-pointer -march=i686 -o smp2 smp.c -L/usr/local/lib
-llthread
# ./smp2
4Gb per pass mode
INTEGER | WRITING 8 Kb block: 2697 Mb/s
res0: 1349
res1: 1348
---
Regards,
Rhett
________________________________________________________________________
Want to chat instantly with your online friends? Get the FREE Yahoo!
Messenger http://uk.messenger.yahoo.com/
[-- Attachment #2 --]
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/time.h>
#include <pthread.h>
#define KILO (1024) /* a conversion multiplier */
#define STARTBLOCK (8) /* in Kbytes */
#define MEMARRAY (16) /* in Mbytes */
#define MEMPASS (4) /* in Gbytes */
typedef signed long S32;
typedef unsigned long U32;
typedef double F64;
typedef struct pack {
U32 memarr;
U32 mempass;
U32 block;
} pack_t;
void intwr(pack_t *data) {
U32 passnum, ret, a, b, c;
F64 start, finish;
volatile U32 *mem;
struct timeval timer;
mem = (U32 *) malloc(data->memarr*KILO*KILO);
passnum = data->mempass*KILO*KILO/data->block;
gettimeofday(&timer, NULL);
start = (F64)timer.tv_sec + ((F64)timer.tv_usec * 1.e-6);
for(a = 0; a < passnum; a++) {
for(b = 0; b < data->block*KILO/sizeof(S32); b += 32) {
mem[b] = 0; mem[b+1] = 0; mem[b+2] = 0; mem[b+3] = 0;
mem[b+4] = 0; mem[b+5] = 0; mem[b+6] = 0; mem[b+7] = 0;
mem[b+8] = 0; mem[b+9] = 0; mem[b+10] = 0; mem[b+11] = 0;
mem[b+12] = 0; mem[b+13] = 0; mem[b+14] = 0; mem[b+15] = 0;
mem[b+16] = 0; mem[b+17] = 0; mem[b+18] = 0; mem[b+19] = 0;
mem[b+20] = 0; mem[b+21] = 0; mem[b+22] = 0; mem[b+23] = 0;
mem[b+24] = 0; mem[b+25] = 0; mem[b+26] = 0; mem[b+27] = 0;
mem[b+28] = 0; mem[b+29] = 0; mem[b+30] = 0; mem[b+31] = 0;
}
}
gettimeofday(&timer, NULL);
finish = (F64)timer.tv_sec + ((F64)timer.tv_usec * 1.e-6);
ret = (U32)((F64)(data->mempass*KILO)/(finish-start));
free((U32 *) mem);
pthread_exit((void *) ret);
}
int main(int argc, char *argv[]) {
U32 res0 = 0, res1 = 0;
pack_t data;
pthread_t thrid0, thrid1;
data.memarr = MEMARRAY;
data.mempass = MEMPASS;
data.block = STARTBLOCK;
printf("%ldGb per pass mode\n\n", data.mempass);
printf("INTEGER | WRITING %6ld Kb block: ", data.block);
pthread_create(&thrid0, NULL, (void *)intwr, (void *)&data);
pthread_create(&thrid1, NULL, (void *)intwr, (void *)&data);
pthread_join(thrid0, (void *)&res0);
pthread_join(thrid1, (void *)&res1);
printf("%ld Mb/s\nres0: %ld\nres1: %ld\n", res0 + res1, res0, res1);
return(0);
}
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030901021331.82307.qmail>
