Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Re: C Multithreading variable memorization

115 views
Skip to first unread message

Francis Glassborow

unread,
Apr 25, 2013, 6:23:19 PM4/25/13
to
On 16/04/2013 02:00, andreaes...@gmail.com wrote:
> Hi all,
> can someone explain me how variables are stored in a multithreading program?
Is there an outline?Does it depends on compiler or SO?How is the memory
divided?
Thank you for your replay.
>


C (in common with most other programming languages) does bot specify how
things are done only what the results shall be. An implementation is
free to provide storage for variables in any way that it sees fit. A
stack per thread is not uncommon but there are other ways (linked frames
will do as well and has been used on some systems)

The question is 'Why does it matter to you as a programmer?'

Implementers have to worry about these (often hardware dependant)
details the rest of us only have to worry if they get it wrong.
--
comp.lang.c.moderated - moderation address: cl...@plethora.net -- you must
have an appropriate newsgroups line in your header for your mail to be seen,
or the newsgroup name in square brackets in the subject line. Sorry.

Herbert Rosenau

unread,
Apr 25, 2013, 6:23:28 PM4/25/13
to
Am 16.04.2013 03:00, schrieb andreaes...@gmail.com:
> Hi all,
> can someone explain me how variables are stored in a multithreading program?Is there an outline?Does it depends on compiler or SO?How is the memory divided?Thank you for your replay.
>
There is no difference to single threaded applications. It is on you to
serialise access when you need to share with other threads.

Barry Schwarz

unread,
Apr 25, 2013, 6:23:22 PM4/25/13
to
On Mon, 15 Apr 2013 20:00:24 -0500 (CDT), andreaes...@gmail.com
wrote:

>Hi all,
>can someone explain me how variables are stored in a multithreading program?Is there an outline?Does it depends on compiler or SO?How is the memory divided?Thank you for your replay.

It is completely implementation specific.

--
Remove del for email

Jasen Betts

unread,
May 1, 2013, 8:19:58 PM5/1/13
to
On 2013-04-16, andreaes...@gmail.com <andreaes...@gmail.com> wrote:
> Hi all,
> can someone explain me how variables are stored in a multithreading
> program?

AFAIK mutlithreading is not part of the C standard. If you asked this
in comp.lang.c you could probbly get shouted at.

> Is there an outline?

trpically "auto" variables are private to your thread and globals and
static variables are shared betwen threads. library functions that
were implemented using static variables are not "thread safe" and hee
are often thread safe variants privided

> Does it depends on compiler or SO?

some vendors provide a mechanism for some static variables to be made
private to the thread. check your compiler documentation

> How is the memory divided?

not sure what you mean.

--
⚂⚃ 100% natural

--- news://freenews.netfront.net/ - complaints: ne...@netfront.net ---

Dag-Erling Smørgrav

unread,
May 8, 2013, 1:37:33 PM5/8/13
to
Jasen Betts <ja...@xnet.co.nz> writes:
> AFAIK mutlithreading is not part of the C standard.

It is in C11.

DES
--
Dag-Erling Smørgrav - d...@des.no

Robert Wessel

unread,
May 8, 2013, 1:37:36 PM5/8/13
to
On Wed, 1 May 2013 19:19:58 -0500 (CDT), Jasen Betts
<ja...@xnet.co.nz> wrote:

>On 2013-04-16, andreaes...@gmail.com <andreaes...@gmail.com> wrote:
>> Hi all,
>> can someone explain me how variables are stored in a multithreading
>> program?
>
>AFAIK mutlithreading is not part of the C standard. If you asked this
>in comp.lang.c you could probbly get shouted at.


C11 added threading.
0 new messages