Subject: pthread/LWP oddity/bug? 27023 related?
To: None <tech-kern@netbsd.org>
From: Reinoud Zandijk <reinoud@netbsd.org>
List: tech-kern
Date: 10/06/2004 00:00:32
--24zk1gE8NUlDmwG9
Content-Type: multipart/mixed; boundary="h31gzZEtNLTqOjlF"
Content-Disposition: inline


--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Dear folks,

in my testing of one of the LWP problem-reports i am working on i ran the 
attached program that creates about a 100 threads that each wait for a 
specified signal... and got the following `output' :

....
load: 2.53  cmd: testing 4574 [sawait sigwait] 0.21u 0.62s 0% 1584k
load: 2.53  cmd: testing 4574 [sawait sigwait] 0.21u 0.62s 0% 1584k
load: 2.97  cmd: testing 4574 [sawait sigwait] 0.21u 0.62s 0% 492k
assertion "next != 0" failed: file "pthread_run.c", line 130, function "pthread__next"
...

with the following backtrace :

#0  0x1005f3dc in pthread__assertfunc () from /usr/lib/libpthread.so.0
#1  0x1005ad0c in pthread__next () from /usr/lib/libpthread.so.0
#2  0x10058cbc in pthread__upcall () from /usr/lib/libpthread.so.0

pthread_run.c :
----------
        } else {
                next = PTQ_FIRST(&pthread__idlequeue);

130:            pthread__assert(next != 0);

                PTQ_REMOVE(&pthread__idlequeue, next, pt_runq);
                pthread__assert(next->pt_type == PT_THREAD_IDLE);
                SDPRINTF(("(next %p) returning idle thread %p\n", self, 
next));
        }
----------

Now does this point to pages not being `wired' or why isnt it just swapping 
it in ?

Cheers,
Reinoud


--h31gzZEtNLTqOjlF
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="test.c"

#include <stdio.h>
#include <signal.h>
#include <pthread.h>
#include <sys/sigtypes.h>

int thou_shallst_exit = 0;


void *start_signal_waiter(void *arg) {
	int signal_num, result_signal;
	sigset_t sigset;

	signal_num = *((int *) arg);

	printf("signal waiting thread %d starting\n", signal_num);

	__sigemptyset(&sigset);
	__sigaddset(&sigset, signal_num);
	do {
		printf("signal waiting thread %d for signal\n", signal_num);
		sigwait(&sigset, &result_signal);
		printf("\tgot signal %d in wait thread %d\n", result_signal, signal_num);
		if (result_signal == SIGTERM) thou_shallst_exit=1;
	} while (!thou_shallst_exit);
	printf("thread %d exiting\n", signal_num);

	pthread_exit(NULL);
}


int main(void) {
	int signal_numbers[100];
	pthread_t signal_threads[100];
	int signal_num;

	for (signal_num=1; signal_num < 100; signal_num++) {
		signal_numbers[signal_num] = signal_num;
		pthread_create(&signal_threads[signal_num], NULL, start_signal_waiter, &signal_numbers[signal_num]);
	};

	/* wait for ever ... (one year or so) */
	sleep(365*24*60*60);

	printf("Sleep times out??? after a year ??\n");
	return 0;
}


--h31gzZEtNLTqOjlF--

--24zk1gE8NUlDmwG9
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBQWMZcoKcNwBDyKpoAQKhLgf/ZH7yc2BZoYFWp+etEXzoldb3Coa4QXtC
KZWAQgtIobj3IHVaDno+KYa1HYaV7CnEC9gNfDY4+wwPa9RBBEYzTX8pxw3KDjIU
GXAFwa7e4t2h1cKjOKj6L2mAMkPeXlTWU2vwkbd9dsdzoqnKUnwR1OUtDKMcEMfp
2g8+aL1M7nUxzhuazQgwvKlNYgjcvr6/3+fDyALlpcgjF/xRcub7pdBk5ihHJhpb
JkGZHGykHca5DstvSxTDTk5x0C9y90weKqywikalHcmZRw3p1jmJIwg2WKdHh4YO
IAbseffbQbkdofMsRO+hp4qh7Gw0QHZQsMGyk+s6RORXQri+BGTLKg==
=NG7f
-----END PGP SIGNATURE-----

--24zk1gE8NUlDmwG9--