pragma section( partition of data segment)

Joined
Jul 10, 2007
Messages
2
Reaction score
0
Hi,

i am trying to write a program, which will be thread, but it will be behave like a process. All of us know that, data segments will not be erase after deleting a thread, till the parent process and all the thread which are using it will die. And i want that, if one of my threads will restart, it will get the refreash data, means reinitialized data which is affiliated to it(only), not all data which is shared
between different threads. For that purpose, i divided the data segment into the sections, and collecting their start address and their length, for that purpose, i am using the pragma sections,But in diab(wind rever) compiler, all the data is not going into their
affiliated section(in which i am trying to force that data, by using the pragma).

What problem i am facing is that:

Problem one: if we are using the pragma section just above a structure definition, then all the object of this type struct are going into the section which is just above the structure definition whether we are trying to put the object in any section.

For example: program is in C++(in C it is working fine)

#pragma section DATA ".first" ".first"
typedef struct
{
int a;
float b;
} abcd;


#pragma section DATA ".second" ".second"
abcd him;

here, "him" variable have to be go into the ".second" section, but it is going into the ".first" section.

Problem two:

if we are declaring external variable in a file following a pragma section, then all the variable which are coming after the extern declaration(i am talking about new definition of variable), are not going into the proper section.

For Example: program is in C++(in C it is working fine)

Text1.cpp

#pragma section DATA ".first" ".first"
unsigned int a,b;


Text2.cpp
#pragma section DATA ".second" ".second"
char m,n;

#pragma section DATA ".third" ".third"
extern unsigned int a;
unsigned int k;


Here, now this "k" variable are going into the second section, but it have to go into the third section.


Shall anyone help me why is it happening, and what is the solution for this problem?

Thanks And Regards
Himanshu
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top