All of lore.kernel.org
 help / color / mirror / Atom feed
* passing arguments to pthreads
@ 2014-03-14 15:08 Daniel Hilst Selli
  2014-03-14 15:46 ` Celelibi
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Hilst Selli @ 2014-03-14 15:08 UTC (permalink / raw)
  To: linux-c-programming

Hi, I have a question about passing multiple arguments to pthreads, the 
big deal is where the paremeters are kept.. I see two possible 
solutions.. keep it on static variables that are never deallocated.. or 
on heap.. so here is my first question

Passing local (stack) variables as arguments to thread is trouble, since 
the scope of this variables can go away before my thread returns..right? 
So forget about local variables

So here is the two options I see, static vs heap...
I'm using this model on one of my applications, is the same senario, a 
function that receives 3 ints as arguments and is called as a thread.. I 
create a little wrapper... here is the code http://pastebin.com/Air7u0YD


How gurus does this? I free the args on threadfd wrapper since, on my 
real application can't join the thread, to be honest, is and deatached 
thread.. Is there something wrong with this strategy, it seems ugly to 
me....

Cheers,


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-03-19  1:44 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-14 15:08 passing arguments to pthreads Daniel Hilst Selli
2014-03-14 15:46 ` Celelibi
2014-03-14 17:30   ` Daniel Hilst Selli
2014-03-14 19:22     ` Celelibi
2014-03-18 22:21       ` Daniel Hilst Selli
2014-03-19  1:44         ` Celelibi

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.