From owner-freebsd-hackers@FreeBSD.ORG Tue Mar 15 04:57:30 2005 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id EC75516A4CE for ; Tue, 15 Mar 2005 04:57:30 +0000 (GMT) Received: from mail.ntplx.net (mail.ntplx.net [204.213.176.10]) by mx1.FreeBSD.org (Postfix) with ESMTP id 8F2B643D58 for ; Tue, 15 Mar 2005 04:57:30 +0000 (GMT) (envelope-from deischen@freebsd.org) Received: from sea.ntplx.net (sea.ntplx.net [204.213.176.11]) j2F4vTwd026705; Mon, 14 Mar 2005 23:57:29 -0500 (EST) Date: Mon, 14 Mar 2005 23:57:29 -0500 (EST) From: Daniel Eischen X-X-Sender: eischen@sea.ntplx.net To: "Michael C. Shultz" In-Reply-To: <200503142014.28897.ringworm01@gmail.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by AMaViS and Clam AntiVirus (mail.ntplx.net) cc: freebsd-hackers@freebsd.org Subject: Re: threads question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Daniel Eischen List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Mar 2005 04:57:31 -0000 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 I'd suggest getting Butenhof's "Programming with POSIX Threads" book. -- DE