Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.os.linux.development.apps > #413
| From | Bill M <wpmccormick@just_about_everywhere.com> |
|---|---|
| Newsgroups | comp.os.linux.development.apps |
| Subject | object file memory |
| Date | 2012-02-06 16:41 -0600 |
| Organization | A noiseless patient Spider |
| Message-ID | <jgpkvf$c83$1@dont-email.me> (permalink) |
I have an object file foo.o that I want to link to an executable. The
main executable creates a number of child threads that use code and
variables from foo.o. I've included a very simplistic representation at
the end. My question is, how can each child thread (worker) get it's own
private copy of global variables foo_char and foo_int? Or does that just
happen auto-magically?
** foo.c **
char foo_char;
int foo_int;
foo_prog(int i, char c) {
foo_char = c;
foo_int = i;
}
** master.c **
extern foo_prog(int, char);
int main(int argc, char** argv)
{
pthread_create(&th1, NULL, worker1, NULL)
pthread_create(&th2, NULL, worker2, NULL)
}
int worker1(void)
{
foo_prog(1,'1');
}
int worker2(void)
{
foo_prog(2,'2');
}
Back to comp.os.linux.development.apps | Previous | Next — Next in thread | Find similar
object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-06 16:41 -0600
Re: object file memory Kaz Kylheku <kaz@kylheku.com> - 2012-02-06 23:07 +0000
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:23 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:40 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 08:58 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 11:21 -0600
Re: object file memory "Ersek, Laszlo" <lacos@caesar.elte.hu> - 2012-02-07 22:09 +0100
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-07 16:08 -0600
Re: object file memory Bill M <wpmccormick@just_about_everywhere.com> - 2012-02-08 20:42 -0600
Re: object file memory Rainer Weikusat <rweikusat@mssgmbh.com> - 2012-02-09 19:00 +0000
Re: object file memory Joe Beanfish <joe@nospam.duh> - 2012-02-09 11:15 -0500
csiph-web