Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
| From | James Kuyper <jameskuyper@verizon.net> |
|---|---|
| Newsgroups | comp.lang.c |
| Subject | Re: Macro for pthread_create() |
| Date | 2012-01-10 18:17 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <4F0CC722.4070907@verizon.net> (permalink) |
| References | <87d3arv2ns.fsf@father.nostromo.wy> <slrnjgp2tc.1hfs.usenet-nospam@guild.seebs.net> <81zkdvz06p.fsf@mother.nostromo.wy> <jeie90$gcj$1@dont-email.me> <81vcojyxag.fsf@mother.nostromo.wy> |
On 01/10/2012 06:04 PM, daniele.g wrote: > Eric Sosman <esosman@ieee-dot-org.invalid> writes: > >> <Off-topic> >> >> ... But it's a dumb idea. The pthread_t variable is your only >> "handle" for the new thread, something you'll need if you later >> want to await the thread's completion or send it a signal or anything >> of that kind. It's a vital part of the machinery, not something that >> should be swept under the rug. > > I do agree. > >> Also, the presence of the declaration means that the macro >> expansion is no longer an expression (it's a declaration plus an >> expression-statement, possibly wrapped in a compound statement). >> Since it's not an expression it has no value, meaning that the value >> returned by pthread_create() is simply lost: You have no way of >> knowing whether thread creation succeeded or failed, and no clue >> as to the cause of a failure. >> >> Why do you think such a macro would be desirable? > > That macro would be desiderable because I need to make it run under > Linux and another OS for embedded systems which doesn't support > pthreads. For now I want it run under Linux for testing. Maybe the macro > is badly defined, and need to be modified. To understand why a macro is needed, it would help to know how you were thinking of defining the macro for the other OS. It's possible that providing two different function definitions, depending upon the OS (possibly with two different declarations) might be clearer and safer than providing two different macro definitions. The macro as you've presented it has one clear advantage: it enforces a naming convention connecting the function and and the thread id. However, it might be better to maintain that connection by other means, such as a structure containing both the thread id and a pointer to the relevant function.
Back to comp.lang.c | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Macro for pthread_create() daniele@father.nostromo.wy (daniele.g) - 2012-01-10 19:21 +0100
Re: Macro for pthread_create() jt@toerring.de (Jens Thoms Toerring) - 2012-01-10 19:02 +0000
Re: Macro for pthread_create() jt@toerring.de (Jens Thoms Toerring) - 2012-01-10 20:18 +0000
Re: Macro for pthread_create() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-10 20:29 +0000
Re: Macro for pthread_create() jt@toerring.de (Jens Thoms Toerring) - 2012-01-10 21:03 +0000
Re: Macro for pthread_create() James Kuyper <jameskuyper@verizon.net> - 2012-01-10 14:14 -0500
Re: Macro for pthread_create() Seebs <usenet-nospam@seebs.net> - 2012-01-10 20:44 +0000
Re: Macro for pthread_create() Anand Hariharan <mailto.anand.hariharan@gmail.com> - 2012-01-13 07:18 -0800
Re: Macro for pthread_create() Seebs <usenet-nospam@seebs.net> - 2012-01-10 19:15 +0000
Re: Macro for pthread_create() daniele@mother.nostromo.wy (daniele.g) - 2012-01-10 23:01 +0100
Re: Macro for pthread_create() Ben Bacarisse <ben.usenet@bsb.me.uk> - 2012-01-10 22:23 +0000
Re: Macro for pthread_create() Keith Thompson <kst-u@mib.org> - 2012-01-10 15:23 -0800
Re: Macro for pthread_create() jt@toerring.de (Jens Thoms Toerring) - 2012-01-10 22:27 +0000
Re: Macro for pthread_create() Keith Thompson <kst-u@mib.org> - 2012-01-10 15:25 -0800
Re: Macro for pthread_create() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-10 17:31 -0500
Re: Macro for pthread_create() daniele@mother.nostromo.wy (daniele.g) - 2012-01-11 00:04 +0100
Re: Macro for pthread_create() James Kuyper <jameskuyper@verizon.net> - 2012-01-10 18:17 -0500
Re: Macro for pthread_create() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-10 18:29 -0500
Re: Macro for pthread_create() Ian Collins <ian-news@hotmail.com> - 2012-01-11 11:54 +1300
Re: Macro for pthread_create() daniele@father.nostromo.wy (daniele.g) - 2012-01-11 10:09 +0100
Re: Macro for pthread_create() Ian Collins <ian-news@hotmail.com> - 2012-01-11 22:20 +1300
Re: Macro for pthread_create() James Kuyper <jameskuyper@verizon.net> - 2012-01-11 11:26 -0500
Re: Macro for pthread_create() daniele@father.nostromo.wy (daniele.g) - 2012-01-12 12:07 +0100
Re: Macro for pthread_create() James Kuyper <jameskuyper@verizon.net> - 2012-01-12 09:19 -0500
Re: Macro for pthread_create() Eric Sosman <esosman@ieee-dot-org.invalid> - 2012-01-12 20:34 -0500
Re: Macro for pthread_create() daniele@father.nostromo.wy (daniele.g) - 2012-01-12 11:52 +0100
Re: Macro for pthread_create() Seebs <usenet-nospam@seebs.net> - 2012-01-11 18:46 +0000
Re: Macro for pthread_create() blp@cs.stanford.edu (Ben Pfaff) - 2012-01-11 11:12 -0800
csiph-web