Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.programming.threads > #689

Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe?

From blmblm@myrealbox.com <blmblm.myrealbox@gmail.com>
Newsgroups comp.programming.threads
Subject Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe?
Date 2011-11-25 17:49 +0000
Organization None
Message-ID <9ja2ooFmj4U2@mid.individual.net> (permalink)
References <4EC9C581.405E@2ndquadrant.com> <cae6c8c3-6406-485e-8cc2-7cda775a5f8d@h31g2000pro.googlegroups.com> <x662id43re.fsf@2ndquadrant.com> <4ecad9c6$0$6961$e4fe514c@news2.news.xs4all.nl>

Show all headers | View raw


In article <4ecad9c6$0$6961$e4fe514c@news2.news.xs4all.nl>,
Casper H.S. Dik  <Casper.Dik@OrSPaMcle.COM> wrote:
> Johann 'Myrkraverk' Oskarsson <johann@2ndquadrant.com> writes:
> 
> >David Schwartz <davids@webmaster.com> writes:
> 
> >> On Nov 20, 11:56 pm, Johann 'Myrkraverk' Oskarsson
> >> <joh...@2ndquadrant.com> wrote:
> >>
> >>> 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.
> >>
> >> Here are the choices you have rejected:
> 
> >I did not reject them.  Both apply code overhead (as in, I write more
> >code) I have to maintain.  The more code I can get rid of the better.
> 
> 
> If it's only one fd, cast it to a pointer and use the pointer as an
> integer; there is really no reason to interpret the pointer as a
> pointer, right?
> 

There was a discussion of this topic in comp.lang.c recently:

http://groups.google.com/group/comp.lang.c/browse_thread/thread/9ce104bbf47d3fbc/c96cd19501ef372b?hl=en&q=#c96cd19501ef372b

I'm not sure it reached consensus, but the arguments against this
"use the pointer parameter to pass an integer" approach seemed
to boil down to "not guaranteed to work on all platforms" and
"likely to confuse other readers of the code".  To me the latter 
alone is a good reason to avoid it, but -- <shrug>.

-- 
B. L. Massingill
ObDisclaimer:  I don't speak for my employers; they return the favor.

Back to comp.programming.threads | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Johann 'Myrkraverk' Oskarsson <johann@2ndquadrant.com> - 2011-11-21 03:29 +0000
  Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Ian Collins <ian-news@hotmail.com> - 2011-11-21 20:00 +1300
    Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Marcel Müller <news.5.maazl@spamgourmet.com> - 2011-11-21 08:48 +0100
    Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Johann 'Myrkraverk' Oskarsson <johann@2ndquadrant.com> - 2011-11-21 07:56 +0000
      Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Ian Collins <ian-news@hotmail.com> - 2011-11-21 21:01 +1300
      Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? David Schwartz <davids@webmaster.com> - 2011-11-21 12:06 -0800
        Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Johann 'Myrkraverk' Oskarsson <johann@2ndquadrant.com> - 2011-11-21 20:30 +0000
          Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Casper H.S. Dik <Casper.Dik@OrSPaMcle.COM> - 2011-11-21 23:07 +0000
            Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Johann 'Myrkraverk' Oskarsson <johann@2ndquadrant.com> - 2011-11-22 05:31 +0000
            Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? blmblm@myrealbox.com <blmblm.myrealbox@gmail.com> - 2011-11-25 17:49 +0000
          Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? David Schwartz <davids@webmaster.com> - 2011-11-23 12:53 -0800
  Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? Robert Wessel <robertwessel2@yahoo.com> - 2011-11-21 02:28 -0600
  Re: Is pthread_create( id, 0, f, &something_on_my_stack ); safe? "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2011-11-22 21:06 +0100

csiph-web