(Etiquette note: it's usual to snip signatures when you reply. The
is the thing after a line consisting only of "-- ".)
Iam an embedded software professional for 3 years and iam migrating
from assembly language to C.(predominantly communication protocol
related)
Since in microcontrollers/processors memory is considered valuable,
iam trying to learn the better way of writing C code.
This is a good reason to be concerned about your C implementation's
memory layout. But you have to realise that different implementations
may do different things. [I have no real experience writing for
embedded systems; there are those here who have and may be able to
point you to useful resources.] The first thing I think you should
consult is your C implementation's documentation: I would be surprised
if an embedded-C compiler didn't go into quite a lot of detail about
memory allocation, optimisation choices, non-Standard but very useful
(maybe essential) features of the implementation, etc. If you have
colleagues who have used that system, or you can find a forum or
mailing list for it, you can probably get more specific help.
[Historically-and-in-my-experience, this newsgroup is more concerned
with implementation-/in/dependant aspects of C programming, of which
there are quite enough to fill a newsgroup or seventeen; trying to
deal with all the embedded-implementation aspects would likely
reduce the group to spaghetti-and-razorblade soup. Also HAIME,
there have been debates, some heated, as to whether this is the
best choice ...]
so when i switch between each thread i wanted to know where the data
is being stored and whether the memory used by automatic variables
inside functions or threads is being reused.
That will be implementation-specific: Standard C doesn't even have
threads. For any sane thing I'd call a "thread", however, each
thread will have its own space for automatic variables -- they
won't interfere with each other.
A warning: when moving from one language (eg assembler) to another
(eg C) it's very easy to be obsessed with getting exactly the same
out of the new language as you did with the old. /You will have to
give up something/ in the transition; in return, you get something
else. One hopes what you get more than pays for what you give up,
but to get the benefits you have to be prepared to shift your ground.
[Don't expect idiomatic Spitbol programs to have the same structure as
Pascal programs: it doesn't work like that. At all. Fortunately, I
was young at the time, it was only coursework, and I learned a useful
lesson.]