Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 14 Mar 2005 21:10:32 -0800
From:      "Michael C. Shultz" <ringworm01@gmail.com>
To:        Daniel Eischen <deischen@freebsd.org>, freebsd-hackers@freebsd.org
Cc:        reso3w83@verizon.net
Subject:   Re: threads question
Message-ID:  <200503142110.33053.ringworm01@gmail.com>
In-Reply-To: <Pine.GSO.4.43.0503142350110.9058-100000@sea.ntplx.net>
References:  <Pine.GSO.4.43.0503142350110.9058-100000@sea.ntplx.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday 14 March 2005 08:57 pm, Daniel Eischen wrote:
> On Mon, 14 Mar 2005, Michael C. Shultz wrote:
> > Hi, I've just reached a point in a program I'm writing where I'd
> > like to do threading.
> >
> > When I try to start a thread like this:
> >
> > pthread_create(&thread, &attr, MGPMrUpgrade, property );
>
>                                                ^^^^^^^^  &property
>
> You should compile with -Wall and get rid of any warnings.
>
> > where property is a structure of many variables it doesn't get
> > passed to the function.  If I do this:
> >
> > pthread_create(&thread, &attr, MGPMrUpgrade( &property ), NULL );
>
> That looks like it will actuall call MGPMrUpgrade() and use its
> return value as the function pointer.
>
> > It works, but just seems wrong.
> >
> > Can anyone point me to a source file, preferably in /usr/src
> > somewhere that passes a structure to a function being run as a
> > thread so I may study the proper way to do this?
>
>   src/lib/libpthread/test/sem_d.c
>   src/lib/libpthread/test/mutex_d.c
>   src/lib/libpthread/test/sigwait_d.c

Great!
>
> I'd suggest getting Butenhof's "Programming with POSIX Threads" book.

I did a google on "Programming with POSIX Threads" and this site popped 
up first.  I remember this guy's stuff from way back when on signals I 
think, it was great for a beginner so maybe this one is worth looking 
at too.
 
"http://users.actcom.co.il/~choo/lupg/tutorials/multi-thread/multi-thread.html"

I found the book at Amazon, thanks for the tip!

Many thanks!

-Mike



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200503142110.33053.ringworm01>