How to properly configure NGPT on an UP system?
Marc Rocas <[email protected]>
| Newsgroups | gmane.linux.ngpt.devel |
|---|---|
| Message-ID | <[email protected]> |
All, I applied the futex-patch to 2.4.19 base kernel which I run on a RedHat 7.3 system using glibc-2.2.5-39.i686 on an old PII 450MHz UP system. Not being altogether familiar on how to compile MT apps on Linux (coming from Solaris, sorry), I thought I would type a simple example (thread-create.c) from the book "Advance Linux Programming" by Mark Mitchell et al that simply has one thread running a loop printing `x' characters and another, the main thread, printing `o' characters. Now the output is supposed to have x's and o's. I was surprised when I ran the executable linked against NGPT only printing o's. I recompiled against linuxThreads and saw the expected output, x's and o's. I also ran the test program on Solaris 8 and 9 on UP and DP systems which also printed a mix of x's and o's. I then modified the test program to use PTHREAD_SCOPE_SYSTEM threads and also added a nanosleep in the loops (turned on by providing any argument to the test program). Running the modified test program without the nanosleep still only produces o's. When the nanosleep is used, the program prints x's and o's. At this point, I'm sure I have not properly configured NGPT. I looked at the archive of the NGPT list but could not gleam anything specific that I should have done other than what is provided by default by the configure script. Could someone point me to some documentation (or design spec) on how best to figure this out. Thanks in advance for your time. --Marc Rocas [email protected] PS. The thread-create.c and Makefile used to compile the test program are below. % cat thread-create.c #include <pthread.h> #include <stdio.h> #include <time.h> static const struct timespec yield_time = {0, 1}; /* default precision */ static unsigned int yieldflg = 0; void * print_xs(void *unused) { while (1) { fputc('x', stderr); if (yieldflg) nanosleep(&yield_time, NULL); } return (NULL); } int main(int argc, char *argv[]) { pthread_attr_t attr; pthread_t tid = 0; if (argc > 1) yieldflg = 1; pthread_attr_init(&attr); pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); if (pthread_create(&tid, &attr, &print_xs, NULL)) { perror("pthread_create"); exit(1); } while (1) { fputc('o', stderr); if (yieldflg) nanosleep(&yield_time, NULL); } return (0); } % cat Makefile all: cc -o thread-create thread-create.c \ -O3 -fomit-frame-pointer -march=i686 \ -I/opt/ngpt/include \ -L/opt/ngpt/lib \ -Wl,-rpath /opt/gcc-3.2/lib -Wl,-rpath /opt/ngpt/lib \ -lpthread