| www.delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mail set sender to djgpp-bounces using -f |
| From: | Georg <dosusb AT googlemail DOT com> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Pipe() |
| Date: | Sat, 16 Jul 2011 05:12:31 -0700 (PDT) |
| Organization: | http://groups.google.com |
| Lines: | 57 |
| Message-ID: | <9ba183b7-6494-408f-80c9-82fa1fc8493f@34g2000yqr.googlegroups.com> |
| References: | <639f9631-f9d6-42b8-bf70-f943afe5afa8 AT n28g2000vbs DOT googlegroups DOT com> |
| <d87c0a0f-09dd-4f0d-a175-78399d1f4ccb AT g12g2000yqd DOT googlegroups DOT com> | |
| <9b97a0e5-b352-406d-9504-9947629f7d69 AT s17g2000yqs DOT googlegroups DOT com> | |
| <554b20d9-38c3-4a0b-9769-01cf2cc59884 AT w24g2000yqw DOT googlegroups DOT com> | |
| <83r55udlym DOT fsf AT gnu DOT org> <2c2cb23a-846a-4c08-9052-ce12066b1d99 AT e8g2000yqi DOT googlegroups DOT com> | |
| NNTP-Posting-Host: | 92.250.191.164 |
| Mime-Version: | 1.0 |
| X-Trace: | posting.google.com 1310818459 4712 127.0.0.1 (16 Jul 2011 12:14:19 GMT) |
| X-Complaints-To: | groups-abuse AT google DOT com |
| NNTP-Posting-Date: | Sat, 16 Jul 2011 12:14:19 +0000 (UTC) |
| Complaints-To: | groups-abuse AT google DOT com |
| Injection-Info: | 34g2000yqr.googlegroups.com; posting-host=92.250.191.164; posting-account=v5xbdQoAAAAOGc9Ccc-kLZyobvPlN3Qr |
| User-Agent: | G2/1.0 |
| X-HTTP-Via: | 1.1 TAS-4-4.man-a |
| X-Google-Web-Client: | true |
| X-Google-Header-Order: | UALSERCVNKH |
| X-HTTP-UserAgent: | Mozilla/5.0 (Windows; U; Windows NT 5.1; de; rv:1.9.1.4) |
| Gecko/20091016 Firefox/3.5.4,gzip(gfe) | |
| Bytes: | 2903 |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
I tried the Minix examples Rugxulo mentioned in the other thread by
converting the makefiles to DOS.
I observed that a sleep() statement in a thread causes a hang with
gthreads. GNU pth 2.07 did continue to work.
Since the Wikipedia example for pthread is the most simple I am aware
of I inserted the sleep() statement there:
#include <pthread.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#define NUM_THREADS 5
void *TaskCode(void *argument)
{
int tid;
tid = *((int *) argument);
sleep(3); /*this is for testing sleep() in a thread */
printf("Hello World! It's me, thread %d!\n", tid);
return NULL;
}
int main (int argc, char *argv[])
{
pthread_t threads[NUM_THREADS];
int thread_args[NUM_THREADS];
int rc, i;
/* create all threads */
for (i=0; i<NUM_THREADS; ++i) {
thread_args[i] = i;
printf("In main: creating thread %d\n", i);
rc = pthread_create(&threads[i], NULL, TaskCode, (void *)
&thread_args[i]);
assert(0 == rc);
}
/* wait for all threads to complete */
for (i=0; i<NUM_THREADS; ++i) {
rc = pthread_join(threads[i], NULL);
assert(0 == rc);
printf("In main: thread %d joined\n",i);
}
printf("\nAll threads joined\n");
exit(EXIT_SUCCESS);
}
This code will work with pth/pthread but hang at sleep() with
gthreads.
Georg
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |