*BSD News Article 96203


Return to BSD News archive

#! rnews 1539 bsd
Path: euryale.cc.adfa.oz.au!newshost.carno.net.au!harbinger.cc.monash.edu.au!news.mira.net.au!news.netspace.net.au!news.mel.connect.com.au!news.mel.aone.net.au!inferno.mpx.com.au!news
From: "Peter Marks" <peter.marks@pobox.com>
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: pthreads, how to get started?
Date: 26 May 1997 21:28:03 GMT
Organization: Microplex Pty Ltd
Lines: 44
Message-ID: <01bc6a1b$bac894e0$0200a8c0@pip.accinform.com.au>
NNTP-Posting-Host: dialup-2b47.mpx.com.au
X-Newsreader: Microsoft Internet News 4.70.1155
Xref: euryale.cc.adfa.oz.au comp.unix.bsd.freebsd.misc:41638

I'm trying to use pthreads under FreeBSD 2.2.1. As instructed in man
pthread I have:

           cd /usr/src/lib/libc_r

           make depend && make all && make install

Then I built the tiny source shown below with this incantation:

threadtest:
        g++ -o threadtest threadtest.cxx /usr/lib/libc_r.a

That's fine (well it doesn't complain). But when I run the program it just
kind of hangs there, but is way up the list if I run top. Can anyone tell
me what I've missed?

Here's the source to threadtest.cxx:

#include <iostream.h>
#include <pthread.h>

void *runme(void *);

int main()
{
        pthread_t       thread;
        pthread_attr_t  *attr = 0;
        cout << "hello" << endl;

         pthread_create(&thread, attr, runme, "hello thread");

        cout << "done" << endl;
}

void *runme(void *arg)
{
        cout << "hello, from thread" << endl;
}

If you can help, please mailto:peter.marks@pobox.com

Many thanks.

peter