|
There is no special asm emitted for volatile variables (in x86/x64). It is used by the compiler to restrict optimizations and control instruction ordering only. As Stuart mentioned, it isn't a lot of use (by itself) in mt programming.
Normally you'd want a lock, but a quick scan of your code seems to indicate that the algorithm ensures that main() and ThreadFunc() will always be reading/writing different buffer.data[] indicies - you'd want to make sure this is true, in some sort of formal proof, before letting the code go live.
So, in your case, after ThreadFunc() writes to buffer.data[i] and releases main() to read it, the cpu cache coherency mechanism (x86/x64) will make sure that main() sees the new version of buffer.data[i] if it is running on a different core. You don't need to do anything to make this happen.
See: http://web.ics.purdue.edu/~jvaught/education/EE563_work/lecture/x86_memory_slides.pdf[^]
...cmk
The idea that I can be presented with a problem, set out to logically solve it with the tools at hand, and wind up with a program that could not be legally used because someone else followed the same logical steps some years ago and filed for a patent on it is horrifying.
- John Carmack
|
|
|
|
|
Folks, I have been told that there is one logical problem with this code. Basically, this is an implementation of the library function strcat().
The intended beahviour of this function to concatenate ct to the end of s. Return s.
I could not find any logical problems with the code, apart from the fact that the final string should be NULL terminated, but I am not sure that can be classified as an error.
Could you help me find the error, if there is any.
char *strcat(char *s, const char *ct)
{
int i, start;
start = strlen(s);
for (i = 0; i < strlen(ct); i++)
{
s[start + i] = ct[i];
}
return s;
}
P.S. -
Is this the only correction needed in the code:
s[start+i]='\0'; \\after the loop
|
|
|
|
|
kaku_lala wrote: P.S. -
Is this the only correction needed in the code:
s[start+i]='\0'; \\after the loop
This should happen as part of the normal "copy" loop. For example:
...
while (*s++ = *ct++)
;
return s;
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
If execute, 'Ho' comes out
It is normally though come out '0000' like this
I am carried cost 'Ho'
IDC_LAT cost is carried how
web
modified on Thursday, May 7, 2009 1:56 PM
|
|
|
|
|
yunpil wrote: I come out 'ho' A if execute
It is normally though caption comes out '0000' like this without should come out
I am carried ho cost
IDC_LAT cost is carried how
Was that english ? Seriously, I didn't understand anything about your question. I even don't understand what you are talking about...
|
|
|
|
|
Why do you expect that much from Google Translate
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Is it a poem?
"Poems, no less! Poems, everybody! The laddie reckons himself a poet!".
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
There isn't even a question in there.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Can you more explain,please?
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
Hi,
I am trying to use RasGetCustomAuthData() function. this is giving required out put for admin user. But not working correctly for non admin user. Can any one suggest a way out?
Thanks in advance.
birajendu
CyberG India
Delhi
India
|
|
|
|
|
I use in my program MFC to download files from the internet, and I want to know if it will work through an authenticating proxy server.
This is my CInternetSession object:
m_pInternetSession = new CInternetSession("Microsoft Internet Explorer 5.0");
And this is CInternetSession constructor from MFC sources.
#define PRE_CONFIG_INTERNET_ACCESS INTERNET_OPEN_TYPE_PRECONFIG
.................................
CInternetSession(LPCTSTR pstrAgent = NULL,
DWORD_PTR dwContext = 1,
DWORD dwAccessType = PRE_CONFIG_INTERNET_ACCESS,
LPCTSTR pstrProxyName = NULL,
LPCTSTR pstrProxyBypass = NULL,
DWORD dwFlags = 0);
So it uses INTERNET_OPEN_TYPE_PRECONFIG by default.
And this is written about INTERNET_OPEN_TYPE_PRECONFIG in MSDN:
Use INTERNET_OPEN_TYPE_PRECONFIG to instruct your application to retrieve the configuration from the registry
So does that mean that my program will correctly load any proxy settings that were set for internet explorer and how can I check that? I've never really used proxies, so I'm at a loss here.
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
Have you tried it to see if it does work or not?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
How can I check if it works? I myself don't connect through a proxy, this issue happens with a client.
Is there any way I can use a public proxy to make a test?
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
sashoalm wrote: How can I check if it works? I myself don't connect through a proxy, this issue happens with a client.
Is there any way I can use a public proxy to make a test?
I think you can make Fiddler[^] act as a proxy that requires authentication. You could test it with that?
Fiddler's an incredibly useful tool to have anyway if you're doing lower-level web development, as you are - it's like Visual Studio's debugger, but for web traffic!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for the link. I installed Fiddler, and I see that it has set my connection settings to use proxy at 127.0.0.1:8888, so it should be working. But I couldn't find any option to make it issue authentification challenges (I checked in Tools->Fiddler Options)
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
It might need scripting (if it's possible) - have a look at this page[^]
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Thanks for your help, it worked. I now get an auth. request when I start Internet Explorer, and I found where the problem with our app is. Btw it didn't need scripting, there was a menu entry "Rules->Require Proxy Authentification".
There is sufficient light for those who desire to see, and there is sufficient darkness for those of a contrary disposition.
Blaise Pascal
|
|
|
|
|
So there is!
Glad it worked for you!
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
As an alternative to Fiddler, Squid[^] is a well-respected web proxy that (may be) easy to install and configure. It supports authentication (including HTTP Basic and Windows NTLM), so would probably make a good simulation of your customer's scenario (hey - they might use Squid, in which case you could use their configuration to guide you possibly?).
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
ok, so i have a dialog, which i'll call CMainDlg.
CMainDlg has a regular CSplitterWnd with two columns.
the splitter has two CWnd derived objects in it, which i'll call CNewWnd
so here's how i created them:
(inside CMainDlg's onInitDialog)
CCreateContext* con = new CCreateContext();<br />
con->m_pNewViewClass = RUNTIME_CLASS(CNewWnd);<br />
<br />
splitter.CreateStatic( this, 1, 2, WS_VISIBLE);<br />
splitter.CreateView(0,0, con->m_pNewViewClass, CSize(200, 200), con);<br />
splitter.CreateView(0,1, con->m_pNewViewClass, CSize(200, 200), con);
that creates the splitters, and the stuff inside them, everything works perfectly, except for the fact that i can't seem to catch the messages from the CNewWnd using ON_NOTIFY
so the problem is, ON_NOTIFY requires the DlgCtrlID like this:
ON_NOTIFY(NM_CLICK, IDD_DLG, func)
but i dont have that value cause the CNewWnd objects are created dynamically
i tried using SetDlgCtrlID() on the CNewWnd objects but it seems to crash the splitter
i also tried sending custom ids using SendMessage but it's not getting caught
(inside CMainDlg)
ON_NOTIFY(NM_CLICK, 15, func)<br />
splitter.GetPane(0, 0)->m_customid = 15;
(inside CNewWnd)
GetOwner->SendMessage(WM_NOTIFY, (WPARAM) m_customid, (LPARAM)hdr);
any suggestions? thanks
|
|
|
|
|
kitkat12012 wrote: i can't seem to catch the messages from the CNewWnd using ON_NOTIFY
so the problem is, ON_NOTIFY requires the DlgCtrlID like this:
ON_NOTIFY(NM_CLICK, IDD_DLG, func)
but i dont have that value cause the CNewWnd objects are created dynamically
It's been a while but I think you want to be notified of WM messages from a CView. NM messages are sent from specific controls.
See here[^]
|
|
|
|
|
When we compile a C/C++ program we get the object code.
Now my doubt is :
When the object code is executed after transferring into the main memory what is it :
1. Is it a PROGRAM or
2. IS it a process....
I got really confused today in my vivas today cause of my examiner....
|
|
|
|
|
A program in execution is called "Process". A program is what you call as .exe. That would also call as an application.
So Program, process, Application all would mean same.
lionelcyril wrote: When the object code is executed after transferring into the main memory what is it :
Also, You don't execute an object code. Your object code gets through linker to make it executable code. .exe
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
Another thing to add is that object code cannot be executed.
It has to be linked by a linker into an executable before it can be executed.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Oops I was just adding it.
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|