[parisc-linux] Problem with atomicity of TIF for parisc ?
Helge Deller
deller at gmx.de
Sun Mar 11 14:24:04 MDT 2007
Hi Dave,
On Saturday 10 March 2007, John David Anglin wrote:
> > Now I'm wondering if our thread-problems may be due the fact that we do not disable interrupts while testing the TIF_XX values in arch/parisc/kernel/entry.S, e.g.:
>
> Do you have a testcase?
Randolph pointed me once to the thread_test2.c testprogram in parisc's 'userspace' CVS repository.
Source is attached, but I haven't tested it since a few weeks...
> I'm still seeing the occasional thread test
> fail in the GCC testsuite fail. These are usually timeouts. I'm not
> seeing hung processes leading to a kernel crash anymore ;)
Me neither.
Helge
-------------- next part --------------
/* gcc -Wall -O2 -o thread_test2 thread_test2.c -lpthread */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <sys/types.h>
#include <sys/wait.h>
pthread_cond_t started, terminated;
pthread_mutex_t started_lock, terminated_lock;
pthread_t thread;
static void *threadfunc(void *data)
{
int *count pid_t pid;
int status;
printf("Thread %d started\n", *count);
pthread_cond_signal(&started);
pid switch (pid) {
case 0: /* Child */
printf("Process %d started\n", *count);
sleep(1);
exit(10);
break;
case -1: /* Error */
perror("fork");
return NULL;
}
printf("Waiting on pid %d\n", pid);
pid if (pid < 0) {
perror("waitpid");
return NULL;
}
printf("Thread %d terminated (%d)\n", *count, WEXITSTATUS(status));
pthread_cond_signal(&terminated);
pthread_exit(NULL);
return 0;
}
int main(int argc, char **argv)
{
int count, ret;
for (count ret if (ret) {
perror("pthread_cond_init(started)");
break;
}
ret if (ret) {
perror("pthread_mutex_init(started_lock)");
break;
}
ret if (ret) {
perror("pthread_cond_init(terminated)");
break;
}
ret if (ret) {
perror("pthread_mutex_init(terminated_lock)");
break;
}
ret if (ret) {
perror("pthread_create");
break;
}
pthread_mutex_lock(&started_lock);
do {
ret } while (ret ! pthread_mutex_unlock(&started_lock);
pthread_mutex_destroy(&started_lock);
pthread_cond_destroy(&started);
pthread_mutex_lock(&terminated_lock);
do {
ret } while (ret ! pthread_mutex_unlock(&terminated_lock);
pthread_mutex_destroy(&terminated_lock);
pthread_cond_destroy(&terminated);
}
return 0;
}
More information about the parisc-linux
mailing list