|
|
hi
this is not a simple berlekamp massey algorithm
i need the simplest algorith to find the linear complexity
the code is available here at codeproject but it is not runnable i do not understand
|
|
|
|
|
Hi,
does anyone know some simple example how to play or capture audio from
internet stream?
Is there any SDK or DirectSound function(s) to implement such think.
Thank you
viliam
|
|
|
|
|
I want to run my exe in admin always irresepective of the user. ofcourse i dont want to run from the run as option. can any one tell me how i will programatically do that.?
birajendu
CyberG India
Delhi
India
|
|
|
|
|
|
Use AdjustTokenPrivileges() . Some examples are here, and in this article about 1/3 of the way down.
"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
|
|
|
|
|
I have written a multithreaded application, and am wondering if I need to declare any of the shared variables as volatile. I have searched online for a while, but have thus far found no definitive source on when you need to use this qualifier. My code operates similarly to the following:
#include <windows.h>
#define ITER_COUNT 300
#define BUFF_SIZE 10
class Buffer {
public:
const size_t length;
const HANDLE canWrite;
const HANDLE canRead ;
double* data ;
size_t writeIdx;
size_t readIdx ;
Buffer(size_t maxSize) :
data(new double[maxSize]()),
writeIdx(0), readIdx(0), length(maxSize),
canWrite(CreateSemaphore(NULL, static_cast<LONG>(maxSize),
static_cast<LONG>(maxSize), NULL)),
canRead (CreateSemaphore(NULL, 0 ,
static_cast<LONG>(maxSize), NULL)) { }
virtual ~Buffer() {
delete[] data;
CloseHandle(canWrite);
CloseHandle(canRead );
}
};
void ThreadFunc(void* var) {
Buffer& buffer(*static_cast<Buffer*>(var));
for (size_t idx = 0; idx < ITER_COUNT; ++idx) {
WaitForSingleObject(buffer.canWrite, INFINITE);
for (size_t j = 0; j < 5; ++j) {
buffer.data[buffer.writeIdx] += idx + j;
}
ReleaseSemaphore (buffer.canRead, 1, NULL);
buffer.writeIdx = (buffer.writeIdx + 1) % buffer.length;
}
}
void main() {
double result = 0;
Buffer buffer(BUFF_SIZE);
HANDLE threadHandle = (HANDLE)_beginthread(&ThreadFunc, 0, buffer);
for (size_t idx = 0; idx < ITER_COUNT; ++idx) {
WaitForSingleObject(buffer.canRead, INFINITE);
result += buffer.data[buffer.readIdx];
buffer.data[buffer.readIdx] = 0;
ReleaseSemaphore (buffer.canWrite, 1, NULL);
buffer.readIdx = (buffer.readIdx + 1) % buffer.length;
}
} Clearly the const members need not be volatile, and the read/write indices are only read or modified in a single thread, so those are ok. However, do I need to declare the Buffer::data pointer as volatile or not?
I have another multithreaded application that has n > 1 threads, such that each thread modifies some data prior to exiting, but does so within a mutex-protected bit of code. Should this variable be declared as volatile as well? Thank you in advance for any assistance.
Sounds like somebody's got a case of the Mondays
-Jeff
modified on Thursday, May 7, 2009 3:41 PM
|
|
|
|
|
volatile means that the variable can be modified at any time without the compiler knowing, which means the compiler must always access the variable and not store it in a register.
I think you'll find that volatile is of limited use in a multi-threaded context - explicit serialisation/control of access to shared data is what is needed - critical sections, mutexes etc...
Don't try to design lock-free structures - they're very, very, very difficult to get right. Use locks and minimise the amount of shared data.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
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
|
|
|
|