Newsgroups: comp.programming.threads Subject: Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? References: <4EC9C581.405E@2ndquadrant.com> <9iub8jF7g0U1@mid.individual.net> From: Johann 'Myrkraverk' Oskarsson Date: Mon, 21 Nov 2011 07:56:50 +0000 Message-ID: User-Agent: Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (usg-unix-v) Cancel-Lock: sha1:UIjwYV5XXV77DNuCFcpm2EhbXpM= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: $$5hrnjedxib4w36u.news.x-privat.org Organization: X-Privat.Org NNTP Server - http://www.x-privat.org Lines: 27 X-Authenticated-User: $$n34o8zi$e5fbcy3tijlef X-Complaints-To: abuse@x-privat.org Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!gegeweb.org!newsfeed.x-privat.org!x-privat.org!not-for-mail Xref: x330-a1.tempe.blueboxinc.net comp.programming.threads:680 Ian Collins writes: Thank you. > On 11/21/11 04:29 PM, Johann 'Myrkraverk' Oskarsson wrote: >> Or, to be a little bit more explicit, is there anything I can use >> for safe argument passing to newly created threads without >> allocating new memory and (presumably) have the threads free it? > > I can't see any problem with > > static int something_on_my_stack = 42; Unfortunately, the numbers are retrieved in a loop. To be extra ex- plicit, file descriptors from accept(), pipe() and friends. I can't see any way that does not involve either 1) memory allocation/freeing or 2) synchronization. Both seem unnecessary code bloat for such a simple task. I did not see it at the first glance at the FAQ. -- Johann Oskarsson http://www.2ndquadrant.com/ |[] PostgreSQL Development, 24x7 Support, Training and Services --+-- | Blog: http://my.opera.com/myrkraverk/blog/