 |
 |
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode HTML tags when pasting" checkbox before pasting anything inside the PRE block, and make sure "Ignore HTML tags in this message" check box is unchecked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question in one forum from another, unrelated forum (such as the lounge). It will be deleted.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
 |
Dear all:
I use enumdisplaysetting api to get the display orientation.
It return different value of the dmDisplayOrientation of DEVMODE structure in the same degree but different graphic.
For example:
If I rotate the screen in 90 degrees counterclockwise, the api
may return 1 with ati graphic, but 3 with nvidia graphic.
How to get same result in the same degree with different graphic? Or other method?
Best regards, Victor
|
|
|
|
 |
Please helps in answering this questions
1.Demonstrate a fragment of a multi-threaded program written in pseudo code in which race condition occurs.
2.Explain what the possibility consequences of the race condition.
3.When is the use of hybrid parallel programming in MPI+OpenMP justified?
4.Why it is more difficult task to ensure the correctness of parallel programms than correctness of sequential programs?
modified 17 hrs ago.
|
|
|
|
 |
Are you and Scholar247 the same person? If so please request removal of one profile.
As to your questions:
- This site does not provide code to order. Google is the place for samples.
- The consequences of a race condition may vary from incorrect results, to a program not responding.
- There are many different situations when this may be appropriate, but it depends on the problem to be solved.
- Impossible to answer as any problem's ease of resolution depends on a lot of factors.
|
|
|
|
 |
int g_x = 0;
DWORD WINAPI Add(void* p) //p unused parameter
{
g_x++;
}
void main()
{
HANDLE m_hArr[10];
int i = 0;
for( ; i < 10; i++ )
{
CreateThread( NULL,0,Add,NULL,0,&m;_hArr[i]);
}
//Wait for all the 10 threads to complete its execution
::WaitForMultipleObjects(10,m_hArr,TRUE,INDEFENITE);
//Now print the result.You expect 10 but it may not be...
cout<<"g_x = "<<g_x<<endl;
}
The above code answers your first question about data race..
|
|
|
|
 |
Because the order of the execution.
Suppose you have 4 floats a,b,c,d
and you want to sum up them.
In case of serial implementation, it will be like a + b + c + d
But in case of parallel, it may execute like
(a+b) + (c+d)
So the result wont be same.
This answers your 4th question.
|
|
|
|
 |
2. Consequence of race condition:
Your resource will go to a corrupted state.
Not getting the expected result etc.,
|
|
|
|
 |
Please can you guys Demonstrate a fragment of a multi-threaded program written in pseudocode which may produce different results from run to run due to round off errors. Explain how it happen
|
|
|
|
 |
Your question is not clear. What is the connection between mult-threading and rounding errors?
|
|
|
|
 |
Richard MacCutchan wrote: What is the connection between mult-threading and rounding errors?
His homework question?
Bad command or file name. Bad, bad command! Sit! Stay! Staaaay...
|
|
|
|
 |
Thanks, I'm not an expert in rounding, but I will stand a round (or around).
|
|
|
|
 |
Overheard many years ago that "C is strongly typed language". So what's up with unspecified / unknown "standard definition " of int abs (int) overloaded by , again unknown source "standard", to <b>float abs ( float)</b>? Is it just "progress" AKA from plain C to C "whatever is latest derivative of it" or just plain lack of real standards ? Happy coding in 2015 Cheers Vaclav
|
|
|
|
|
 |
How does one arbitrarily enable or disable a button on the Ribbon bar?
The OnUpdateCommand handler only allows you to specify a change in response to a button-click. But I want to enable or disable the button from elsewhere in the program.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
 |
Thanks for your response.
That macro allows me to add an OnUpdateCommandUI handler which gets called right after the button is clicked.
But how does it allow me to do something like ribbonButton.Enabled(FALSE); NOT in response to a button click?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
 |
I guess it's just a matter of creating a function that can enable or disable the button, something like:
void EnableButton(CMFCRibbonButton& ribbonButton, bool bEnable)
{
ribbonButton.Enable(bEnable);
}
or better still, a function that enables/disables all the buttons based on a set of rules ...
void EnableButtons(int nRule, bool bEnable)
{
switch (rule)
{
case 1:
ribbonButton1.Enable(bEnable);
ribbonButton2.Enable(bEnable);
break;
case 2:
ribbonButton1.Enable(bEnable);
ribbonButton6.Enable(bEnable);
ribbonButton7.Enable(bEnable);
break;
}
}
You then call this function from elsewhere in response to some arbitrary decision of your own.
|
|
|
|
 |
Now you've hit upon the exact problem: The CMFCRibbonButton does not have an "Enable" method, or any method like it, hence my dilemma.
Thanks again for your time.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
 |
/*
TEST WITH THE FOLLOWING
PROBLEM 1
inputs:
infinity:999
no. of cities: 4
no. of paths:6
PROBLEM 2
inputs:
infinity:999
no. of cities: 5
no. of paths:10
*/
#include
#define ALL -1
#define MAXCITIES 10
enum BOOL{FALSE,TRUE};
long*visited;//visited nodes set here
long*min_circuit;//min inner circuit for given node as start node at position indexed 0
long*ham_circuit;//optimal circuit with length stored at position indexed 0
long min_circuit_length;//min circuit lenth for given start node
int n;//city count
long matrix[MAXCITIES][MAXCITIES];//nondirectional nXn symmetric matrix
//to store path distances as sourceXdestination
long INFI;// INFINITY value to be defined by user
// function resets minimum circuit for a given start node
//with setting its id at index 0 and setting furthr node ids to -1
void reset_min_circuit(int s_v_id)
{
min_circuit[0]=s_v_id;
for(int i=1;i\n ids varying from 0 to %d\n",n-1);
//init all matrix distances to infinity
for(i=0;i ",ham_circuit[i]);
}
else printf("\n\nNo hamiltonian circuit !");
delete []visited;
delete []min_circuit;
delete []ham_circuit;
}
|
|
|
|
 |
What is your question?
Note: I have deleted your duplicate of this post.
|
|
|
|
 |
HI ALL,
I was working building Visual C++ software using Visual Studio 6.
Now I have Visual Studio 2008 and still have this C++ project.
if I want to rebuild it on Visual Studio 2008, what are the attentions I shall pay?
diligent hands rule....
|
|
|
|
 |
Add the project, build it, and see what happens.
|
|
|
|
 |
good point. based on my research, it shall be the same because Visual Studio 2013 can still build native C++ image.
diligent hands rule....
|
|
|
|
 |
Southmountain wrote: based on my research What research? All versions of Visual Studio build C++ code into a native image.
|
|
|
|