<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2873" name=GENERATOR></HEAD>
<BODY>
<DIV><FONT face=Arial size=2>
<DIV><FONT face=Arial size=2><FONT size=2>
<P>Hi,</P>
<P>I have couple to test programs which get killed on mips, but they run fine on 
fedora core 3 and nptl.</P>
<P>Here are the codes and outputs.</P>
<P>test case 1</P>
<P>===========</P>
<P>#include &lt;stdio.h&gt;</P>
<P>#include &lt;pthread.h&gt;</P>
<P>#include &lt;unistd.h&gt;</P>
<P>#define THREADS_NO 10</P>
<P>pthread_t threads[THREADS_NO];</P>
<P>void *thread_function(void *arg)</P>
<P>{</P>
<P>int no = (int)arg;</P>
<P>printf("Thread %d calling pthread exit.\n", no);</P>
<P>pthread_exit(NULL);</P>
<P>}</P>
<P>int main()</P>
<P>{</P>
<P>int i;</P>
<P>for (i = 0; i &lt; THREADS_NO; i++)</P>
<P>pthread_create(&amp;threads[i], NULL, thread_function, (void *)i);</P>
<P>for (i = 0; i &lt; THREADS_NO; i++)</P>
<P>{</P>
<P>pthread_join(threads[i], NULL);</P>
<P>printf("Completed join with thread %d\n",i);</P>
<P>}</P>
<P>printf("Done joining all threads.\n"); pthread_exit(NULL); }</P>
<P>output</P>
<P>=======</P>
<P># threadtest2-mipsel</P>
<P>Thread 0 calling pthread exit.</P>
<P>Thread 1 calling pthread exit.</P>
<P>Thread 2 calling pthread exit.</P>
<P>Thread 3 calling pthread exit.</P>
<P>Thread 4 calling pthread exit.</P>
<P>Thread 5 calling pthread exit.</P>
<P>Thread 6 calling pthread exit.</P>
<P>Thread 7 calling pthread exit.</P>
<P>Completed join with thread 0</P>
<P>Completed join with thread 1</P>
<P>Completed join with thread 2</P>
<P>Completed join with thread 3</P>
<P>Completed join with thread 4</P>
<P>Completed join with thread 5</P>
<P>Completed join with thread 6</P>
<P>Completed join with thread 7</P>
<P>Killed</P>
<P>test case 2</P>
<P>============</P>
<P>#include &lt;sys/time.h&gt;</P>
<P>#include &lt;signal.h&gt;</P>
<P>#include &lt;fcntl.h&gt;</P>
<P>#include &lt;sys/syscall.h&gt;</P>
<P>#include &lt;sys/mman.h&gt;</P>
<P>#include &lt;stdio.h&gt;</P>
<P>#include &lt;unistd.h&gt;</P>
<P>#include &lt;string.h&gt; /* memset() */</P>
<P>#include &lt;sys/socket.h&gt;</P>
<P>#include &lt;netinet/in.h&gt;</P>
<P>#include &lt;arpa/inet.h&gt;</P>
<P>#include &lt;netdb.h&gt;</P>
<P>#include &lt;sys/types.h&gt;</P>
<P>#include &lt;sched.h&gt;</P>
<P>#include &lt;pthread.h&gt;</P>
<P>#define USER_BUF_SIZE 188*1024*10</P>
<P>typedef struct test</P>
<P>{</P>
<P>int ch;</P>
<P>#define OPT_START 0x00000002</P>
<P>/* streaming parameters */</P>
<P>unsigned char options;</P>
<P>/* internal members */</P>
<P>int fd; </P>
<P>pthread_t producer_thread;</P>
<P>int sig;</P>
<P>pthread_mutex_t mutex;</P>
<P>} test_t;</P>
<P>test_t tests[3];</P>
<P>/* Main loop of the Reader Thread - the task of this function is to read 
index data</P>
<P>from filesystem and feed it frame at a time */</P>
<P>void *thread_func(void *data)</P>
<P>{</P>
<P>test_t *pb = (test_t *)data;</P>
<P>unsigned char *index = malloc(256);</P>
<P>unsigned char *userbuf_org; </P>
<P>pthread_attr_t attr;</P>
<P>struct sched_param params;</P>
<P>int scheduler;</P>
<P>char devname[256];</P>
<P>&nbsp;</P>
<P>&nbsp;</P>
<P>userbuf_org = (unsigned char *) malloc(USER_BUF_SIZE+4095);</P>
<P></P>
<P>printf("Thread %p:%p, is starting\n", pb-&gt;producer_thread, 
userbuf_org);</P>
<P></P>
<P>while (1)</P>
<P>{ </P>
<P>pb-&gt;sig=1; </P>
<P></P>
<P></P>
<P>if (!(pb-&gt;options &amp; OPT_START)) {</P>
<P>break;</P>
<P>} else {</P>
<P>sched_yield();</P>
<P></P>
<P>continue;</P>
<P>}</P>
<P></P>
<P>}</P>
<P></P>
<P>printf("Thread %p:%p, is exiting\n", pb-&gt;producer_thread, 
userbuf_org);</P>
<P>out:</P>
<P>free(index);</P>
<P>free(userbuf_org);</P>
<P>pthread_exit(NULL); </P>
<P></P>
<P>return NULL;</P>
<P>}</P>
<P>&nbsp;</P>
<P>int main() {</P>
<P>int i;</P>
<P>test_t * p;</P>
<P>memset(tests, 0, sizeof (tests));</P>
<P>for (i = 0; i &lt; 3; i++) {</P>
<P>p = &amp;tests[i];</P>
<P>p-&gt;ch = i;</P>
<P>p-&gt;sig = 0; </P>
<P>p-&gt;options |= OPT_START;</P>
<P>pthread_create(&amp;p-&gt;producer_thread, NULL, thread_func, (void*)p);</P>
<P>}</P>
<P>getchar();</P>
<P>for (i = 0; i &lt; 3; i++) {</P>
<P>p = &amp;tests[i];</P>
<P>if(p-&gt;sig != 1)</P>
<P>{</P>
<P>fprintf(stderr, "thread %p did not set sig",p-&gt;producer_thread);</P>
<P>continue;</P>
<P>}</P>
<P>p-&gt;options &amp;= ~(OPT_START);</P>
<P>pthread_join(p-&gt;producer_thread, NULL);</P>
<P>printf("currend id %d\n", i);</P>
<P>}</P>
<P>return 0;</P>
<P>}</P>
<P>test case 2 output</P>
<P>===================</P>
<P># pthread_test-mipsel</P>
<P>Thread 0x402:0x2abe0008, is starting</P>
<P>Thread 0x803:0x2adb8008, is starting</P>
<P>Thread 0xc04:0x2af90008, is starting</P>
<P>c</P>
<P>Thread 0x402:0x2abe0008, is exiting</P>
<P>currend id 0</P>
<P>Thread 0x803:0x2adb8008, is exiting</P>
<P>currend id 1</P>
<P>Killed</P>
<P>&nbsp;</P>
<P>Has anybody had problems with pthread_join before. Is this a bug or else can 
somebody give me some pointers on this.</P>
<P>Thanks</P>
<P>Ashwin</P>
<P>&nbsp;</P>
<P>&nbsp;</P></FONT></FONT></DIV></FONT></DIV></BODY></HTML>