|
Sharepoint web-services use SOAP, right? In that case, gSOAP[^] would probably be the best thing to generate C++ bindings compatible with VC6, I suspect.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I'm trying to figure out where exactly I would use the Max-Count value of a Semaphore. What's it's purpose? I have been thinking that when the number of processes trying to access the S-object reaches Initial-Count, Max-Count comes into picture. For example, If I had specified 3 as the initial count, 5 as the Max-Count and I'm invoking 3 processes to fill the initial-Count quota. These 3 successfully wait-through(pass-through) the wait-function. Now I execute the 4th process.. since I had mentioned 5 as Max-Count, I guessed it will allow only two more process to get into the block-wait.So It works, I'm able to put 4th and 5th processes into wait. (Though they don't pass the wait function, they just wait). I thought if I execute the 6th process, it would fail and I would get WAIT_FAILED result. But on the contrary, it keeps to wait along the 4th and 5th process. So I conclude my guess is wrong. Can anybody explain a bit on this max-count? Thanks.
----------------------------
286? WOWW!
|
|
|
|
|
In Windows, a semaphore blocks when its count is zero.
It starts at lInitialCount (as per the documentation[^]).
A successful Wait for the semaphore decreases the count by 1. A ReleaseSemaphore from any thread increases the count by 1. So, if you set the initial count to something less than the max count, if you release the semaphore one or more times before anything waits , it can reach the maximum count.
I suppose that lets you have a notional initial occupancy of the semaphore - but you need to be aware of and keep track of that.
So - in your case, initial count=3, max count=5, so the semaphore believes two of its 'slots' are filled when it is created. The first three waits on the semaphore succeed. Any waits after that will wait until ReleaseSemaphore is called and the thread can acquire the semaphore.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: So - in your case, initial count=3, max count=5, so the semaphore believes two of its 'slots' are filled when it is created. The first three waits on the semaphore succeed. Any waits after that will wait until ReleaseSemaphore is called and the thread can acquire the semaphore.
Is it like at first the limit cap would be 3(As it assumes the other 2 to be filled already) but once we start to release semaphores, the cap would be extended to 5?
For example:
initially available slots: 3 ; Filled slots :2 ; SemVar=3
S1 Created. Successful wait-through. SemVar-- = 2
S2 Created. Successful wait-through. SemVar-- = 1
S3 Created. Successful wait-through. SemVar-- = 0, becomes 0 and becomes non-signled.
S4 Cannot be created. Limit Reached. Keeps Waiting.
S1 Released. SemVar++ = 1 (Now will it add 2 more counts here?) so that SemVar becomes 3 . Hence the final limit becomes 5. (2 already in use S2,S3 after we release S1). So as I just said, the currently available slots would be 3.
Now S4 gets through.
S5 gets through.
S6 Gets through.
So we have S2,S3,S4,S5,S6 in the ultimate list?
Now the semaphore starts to operate on 0 to 5 limits. Rather than the 0 to 3 limit. Did I get you right?
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: Is it like at first the limit cap would be 3
The limit is always 5 - it's just that you start with lInitialCount slots available - the difference between the initial count and the maximum count is the number of used slots when the semaphore is created.
_8086 wrote: S1 Released. SemVar++ = 1 (Now will it add 2 more counts here?)
No - the difference between the initial count and the maximum count is erased when you release the semaphore in threads that never acquired the semaphore. Let's say we have threads T0 and T1 and some worker threads Tw0-Tw5.
Let's say we want to create the semaphore with 5 slots, 2 of which are already reserved for T0 and T1. In that case, we use a maximum count of 5 and an initial count of 3 (5-3=2 slots, for T0 and T1).
Now, the effective count for threads Tw0-Tw5 to use is 3 until a thread that hasn't acquired the semaphore releases it.
So, if thread T0 calls ReleaseSemaphore (remember, it has never waited on the semaphore), the semaphore's effective count goes up to 4. If thread T1 then calls ReleaseSemaphore, its effective count goes up to 5.
Does that make sense?
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: Does that make sense?
Truly.
Let me test this one now. Thanks dude.
----------------------------
286? WOWW!
|
|
|
|
|
Hi Stuart, Let me continue my discussion now. Okay, now as you said, We'd require two threads to release the Semaphore without even acquiring it. Assume we are not doing it. Now the Semaphore variable counter would be 0. What should happen if a new process/thread tries to call CreateSemaphore now?
Should I check for GetLastError()? So that I might get "Limit_reached" or something? Before putting the new handle into Wait function? Or I should pass the handle to the wait function straight and try to get check the value returned by it?
Your answers have been awesome. Thanks a lot.
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: CreateSemaphore
Ummm - it'd create a new semaphore? Or are you creating a named semaphore and using the same name as previously (and if that's the case, the initial and maximum counts are ignored)?
Anyway - CreateSemaphore doesn't matter - it's the wait function[^] that acquires the semaphore. When the semaphore's count is zero, waiting on the semaphore will cause the wait function to block - that's what the documentation[^] says, anyway.
If you use WaitForSingleObject, it will return WAIT_OBJECT_0 if it acquires the semaphore or WAIT_TIMEOUT if the semaphore isn't available (unless you specify a timeout of INFINITE, in which case WaitForSingleObject will never return).
The 'Using Semaphore Objects[^]' page may clarify things.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Stuart Dootson wrote: Ummm - it'd create a new semaphore? Or are you creating a named semaphore and using the same name as previously (and if that's the case, the initial and maximum counts are ignored)?
Yes I've been talking about named semaphores across multiple processes . Also why it init, max counts should be ignored in this case?
Stuart Dootson wrote: If you use WaitForSingleObject, it will return WAIT_OBJECT_0 if it acquires the semaphore or WAIT_TIMEOUT if the semaphore isn't available (unless you specify a timeout of INFINITE, in which case WaitForSingleObject will never return).
Hmm okay now it's clear. I did have a wrong idea. For example, If the initial count = 3, maxcount =5. I thought 3 would get WAIT_OBJECT_ thing, the next 2 Would calls would "successfully-get-blocked" with the wait function. Any other calls after these wouldn't wait successfully. I thought this will also get through the wait function but with some error set in "last-error".
----------------------------
286? WOWW!
|
|
|
|
|
_8086 wrote: Also why it init, max counts should be ignored in this case?
Because the documentation says so[^]
And because it makes a lot of sense for the count parameters to be immutable
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Hi There,
I am using the following example to make Win32 tab control without using MFC.
Win32 SDK C Tab Control made easy[^]
There are some business reasons that I can only use Win32 API for this.
I am able to create the tab pages. But finding weird behaviour with the messageloop.
I am making an XLL, so my dialog is opened from a selection from Excel menu item.I get a dialog box with tabs on clicking this certain menu item. Each tab has some edit boxes and buttons. which all work fine except the TAB key doesnt work to move from one item to another.
I have implemented it the same way as in above program. The problem i face are:
1. When i click on the tabs, it shows me the correct child dialog. when i change the selection of tab, it goes to the correct next dialog. so everything works fine here. But when i click on any area in the child dialog (i.e to activate the message loop), The tab key starts working on that particular selected tab, BUT after this i am not able to select any other tab. On clickin on any other tab takes me to the first tab (iSel=0)
2. When I close the dialog box from the X button in top right corner; It closes the dialog box BUT it also closes my Excel window which i dont want.
This application I am developing to configure and test some connections. so I need the excel window open after i am done with the configurations.
Please reply if you read this message. I will appreciate any help.
Regards
Ajay
ajaymat@gmail.com
|
|
|
|
|
Hello!
Have anyone tried to draw a Gif on a OpenGL Window?
I´m stuck here...
Thaks!
|
|
|
|
|
Anybody know how to convert the following code?
__asm<br />
{<br />
push eax<br />
push edi<br />
<br />
push es<br />
push ecx<br />
<br />
mov edi, [this]<br />
add edi, [m_StartExceptionContext]<br />
push ds<br />
pop es<br />
mov ecx, size m_StartExceptionContext<br />
xor eax, eax<br />
push edi<br />
cld<br />
rep stosb<br />
pop edi<br />
<br />
pop ecx<br />
pop es<br />
<br />
mov dword ptr [edi] CONTEXT.ContextFlags, CONTEXT_FULL<br />
mov dword ptr [edi] CONTEXT.Eax, eax<br />
mov dword ptr [edi] CONTEXT.Ecx, ecx<br />
mov dword ptr [edi] CONTEXT.Edx, edx<br />
mov dword ptr [edi] CONTEXT.Ebx, ebx<br />
mov dword ptr [edi] CONTEXT.Esi, esi<br />
mov dword ptr [edi] CONTEXT.Edi, edi<br />
mov word ptr [edi] CONTEXT.SegSs, ss<br />
mov word ptr [edi] CONTEXT.SegCs, cs<br />
mov word ptr [edi] CONTEXT.SegDs, ds<br />
mov word ptr [edi] CONTEXT.SegEs, es<br />
mov word ptr [edi] CONTEXT.SegFs, fs<br />
mov word ptr [edi] CONTEXT.SegGs, gs<br />
pushfd<br />
pop [edi] CONTEXT.EFlags<br />
mov eax, [ebp]<br />
mov dword ptr [edi] CONTEXT.Ebp, eax<br />
mov eax, [ebp + 4]<br />
mov dword ptr [edi] CONTEXT.Eip, eax<br />
lea eax, [ebp + 8]<br />
mov dword ptr [edi] CONTEXT.Esp, eax<br />
<br />
pop edi<br />
pop eax<br />
}<br />
}
|
|
|
|
|
If that code works, why bother? The assembly code is x86 specific, the necessary intrinsics would be x86 specific as well as being Visual C++ specific - you won't get any cross-platform benefit.
For what that code's doing (looks like it's throwing an exception, whilst storing the full processor context, possibly so it can resume?), I suspect you need assembly language, 'cos the compiler would add in too much unwanted rubbish.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
I need it to compile to an x64 Architecture!! As far as i know VS2005 does not support any inline code (Assembler)..
|
|
|
|
|
Not when compiling 64bit code no.. but AFAIK not all the instructions you used are available as intrinsic functions - actually, most aren't.
The only solution I know is using an other compiler..
|
|
|
|
|
You probably need to do more than just literally translate that code, then - the processor context for the x64 will be different (for example, the 64-bit register set is different) than the x86 context. Have a look at this page on x64 calling conventions[^] - that's very different to x86.
Your best bet might be to rewrite the code as a standalone assembly language file that you can assemble with MASM and then link into your application (that's the easiest way to make sure it works, as you have no compiler bits getting in the way) then use that as a working model to attempt to convert into intrinsics.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
|
I'm using VS2008 Team System. How do I add a web reference to my C++ project?
|
|
|
|
|
Google[^] -> here[^]
You can only add a web reference for a C++/CLR project, not an unmanaged C++ project.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
In VS2005, I used to right click and choose "Add Web Reference". In VS2008, that menu is disabled. Any way to enable it?
|
|
|
|
|
That menu is enabled for me in VS2008 when I have a C++/CLR project. If it's not enabled for you in VS2008 for a C++/CLR project, that says to me that your Visual Studio installation is broken.
The reason Add Web Reference no longer works for unmanaged C++ projects in VS2008 is that ATL Server isn't in VS2008[^]. A simple Google[^] would have shown you that.
You can download ATL Server from CodePlex[^] - it's been open sourced. This includes sproxy.exe, which will generate the C++ wrapper code for the web-service.
The other Microsoft alternative is the Windows Web Services[^], which will be released with Windows 7 and available as an update for Windows XP SP2 and later.
An open-source alternative is gSOAP[^].
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
i think the MFC or unmanaged is means .
how can we add in this kind of project
|
|
|
|
|
In MSDN:
Notifies a service that its startup parameters have changed. The hService handle must have the SERVICE_PAUSE_CONTINUE access right.
Does this mean that I don't need to care about the sync problem between the ControlHandler and ServiceMain function?
|
|
|
|
|
maishuiking wrote: Does this mean that I don't need to care about the sync problem between the ControlHandler and ServiceMain function?
I haven't got a fricking clue and, I suspect, neither will most people on this forum without a little more context describing what you're talking about when you maention "the sync problem".
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|