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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What is 'Debug'? And 'multithreaded'?

Status
Not open for further replies.

cadbilbao

Programmer
Apr 9, 2001
233
ES
Hi!

Compilling with Visual C++ 6.0, which is the meaning of compilling as 'Debug'?

And what does 'multithreaded' mean? I know that there are 'multithreaded' and 'single-threaded', but in wich cases have I to choose each one?

Thank you...
 
Debug mode means to make a program what can be debugged. About multiple thereading, study threads to know what are they for. John Fill
1c.bmp


ivfmd@mail.md
 
also... debug can be very usefull for certain things

for example... lets say you were doing a console app and for debugging you were using cout statements. If you:

#ifdef _DEBUG
cerr>>"I got an error with a null pointer";
#endif

this could be useful information to you. Then when you switch over to "release" you will not have these pre-processor directives.

As for multi-threaded... the general explanation can be though of like this:

3 cars are driving down the road going to the same destination A. They have all been traveling on the same road and they come to a 3 way interseciton. They can either take roads x, y or z to get to A. Car one goes by x, two by y and three by z. Then they meet at A. The cars are the program which then creates the threads (x,y,z) which all run together and then meet up at the end (not necessarilly at the same time). Basically the all drive to the same place concurrently. When the program runs a thread it will run concurrently with the rest of the program and join back to the program at a later time.

Hope you can follow the analogy.


matt
 
Thank you very much, and for the three car example :-D
 
Cadbilbao -

If you're new to C++ and/or C, you might want to wait a bit before diving into multithreaded programming. It's a little complex.

The biggest thing that can bite you is variable access. Say you have two threads, A and B, and a long variable named counter, with an initial value of 4. "A" needs to execute this code:
[tt]counter*=3[/tt]
And "B" needs to execute this code:
[tt]counter+=2[/tt]

The question is: What's the value of counter?
And the answer is: It depends on the order in which the statements were executed.

If thread A executes first, you get 14. If thread B executes first, you get 18. If they execute at the same time (which is possible on a dual-cpu machine), the results are undefined.

So, what you need to make sure is that you try not to access any global variables from within a thread. It's best to lump anything the thread needs into a struct and pass it to the thread routine.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top