Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Versions of an Application 1

Status
Not open for further replies.

sweep123

Technical User
May 1, 2003
185
GB
I have an application that transmits data to a unit, but in the final system they will be 4 applications (all identical).
Now each application will need to detect if another instance of the application is running and adjust one of its parameters.

i.e. the 1st instance will be know as 1, then 2nd needs to determine if 1 is already running and mark itself as 2 etc.

How do you do this? Dont want to use batch files or command line parameters.

Sweep
 
specify in linker parameters:
/section:sweep123

in the .cpp code you will put a segment:
#pragma data_seg( "sweep123 ")
static bool isRunningAlready = false;
static int versionRunning = -1;
.....
#pragma data_seg()

the values from segment sweep123 are shared between processes, so if you change value in one application, you will read changed values from any other applications what has this segment.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
>specify in linker parameters:
>/section:sweep123

Which can easily be done with the pragma comment statement, ie

Code:
#pragma data_seg("sweep123")
bool volatile isRunningAlready = false;
int volatile versionRunning = -1;
#pragma data_seg()

#pragma comment(linker, "/section:sweep123,rws")


/Per
[sub]
if (typos) cout << &quot;My fingers are faster than my brain. Sorry for the typos.&quot;;
[/sub]
 
OK thanks chaps.

Simple when you know how.
 
On other question, can you lock any of the data during an update.

i.e. one instance of the application will be required to update some data. So need to block out the reader durng this activity.

How can this be done?

Sweep
 
yes, for process synchronisation you should use mutex'es.

Ion Filipski
1c.bmp

ICQ: 95034075
AIM: IonFilipski
filipski@excite.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top