Click here to Skip to main content
15,889,844 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: bit extraction from BYTE Pin
«_Superman_»9-Mar-10 23:21
professional«_Superman_»9-Mar-10 23:21 
AnswerRe: bit extraction from BYTE Pin
CPallini9-Mar-10 23:18
mveCPallini9-Mar-10 23:18 
AnswerRe: bit extraction from BYTE Pin
KarstenK10-Mar-10 4:15
mveKarstenK10-Mar-10 4:15 
GeneralRe: bit extraction from BYTE Pin
CPallini10-Mar-10 11:24
mveCPallini10-Mar-10 11:24 
QuestionDialog Box Resize [modified] Pin
shiv@nand9-Mar-10 21:48
shiv@nand9-Mar-10 21:48 
AnswerRe: Dialog Box Resize Pin
Mohan Ramachandra9-Mar-10 21:53
Mohan Ramachandra9-Mar-10 21:53 
AnswerRe: Dialog Box Resize Pin
«_Superman_»9-Mar-10 22:10
professional«_Superman_»9-Mar-10 22:10 
QuestionProblem with WaitForSingleObject for multiple calls to ReleaseSemaphore Pin
temp.cyberfiles9-Mar-10 21:34
temp.cyberfiles9-Mar-10 21:34 
I am creating a blocking API implementation. For that i am using a semaphore which is initialized once in the beginning of the program. A pseudo code of the scenario is given below:


startProgram()
{
initCount = 0; //first call shall wait
semVariable = CreateSemaphore (NULL, initCount, 1, NULL);
}


I am calling the semaphore in my API:

API_my_blocking_func()//thread1
{
//Wait until data is ready in do_unblock()
if(WAIT_TIMEOUT == WaitForSingleObject (semVariable, timeout)
{
return WAIT_TIMEOUT ;
}

continues........

}


meanwhile in another thread, when data is ready, I am releasing semaphore so that API_my_blocking_func() continues.

do_unblock() //trhead2
{
if(data is ready)
ReleaseSemaphore (semVariable, 1, NULL);
}

----

Now I am having a problem : If ReleaseSemaphore (with semVariable) is called two times due to some reason,
the WaitForSingleObject is not waiting!

To my expectation, since the maximum count is set to 1 , releasing the semaphore
shall not increment semVariable above 1, whatever be the number of calls to ReleaseSemaphore . So the very next
WaitForSingleObject shall block.

How to achieve multiple release of semaphore is allowed, and a single WaitForSingleObject on the same semaphore shall block?
AnswerRe: Problem with WaitForSingleObject for multiple calls to ReleaseSemaphore Pin
Cool_Dev9-Mar-10 22:09
Cool_Dev9-Mar-10 22:09 
GeneralRe: Problem with WaitForSingleObject for multiple calls to ReleaseSemaphore Pin
temp.cyberfiles9-Mar-10 22:26
temp.cyberfiles9-Mar-10 22:26 
GeneralRe: Problem with WaitForSingleObject for multiple calls to ReleaseSemaphore Pin
Cool_Dev9-Mar-10 22:29
Cool_Dev9-Mar-10 22:29 
QuestionHow to register an ActiveX ocx file Pin
rahul.kulshreshtha9-Mar-10 20:16
rahul.kulshreshtha9-Mar-10 20:16 
AnswerRe: How to register an ActiveX ocx file Pin
«_Superman_»9-Mar-10 20:24
professional«_Superman_»9-Mar-10 20:24 
GeneralRe: How to register an ActiveX ocx file Pin
rahul.kulshreshtha9-Mar-10 20:26
rahul.kulshreshtha9-Mar-10 20:26 
GeneralRe: How to register an ActiveX ocx file Pin
Rajesh R Subramanian9-Mar-10 20:28
professionalRajesh R Subramanian9-Mar-10 20:28 
GeneralRe: How to register an ActiveX ocx file Pin
rahul.kulshreshtha9-Mar-10 20:29
rahul.kulshreshtha9-Mar-10 20:29 
GeneralRe: How to register an ActiveX ocx file Pin
«_Superman_»9-Mar-10 20:28
professional«_Superman_»9-Mar-10 20:28 
GeneralRe: How to register an ActiveX ocx file Pin
rahul.kulshreshtha9-Mar-10 21:05
rahul.kulshreshtha9-Mar-10 21:05 
GeneralRe: How to register an ActiveX ocx file Pin
rahul.kulshreshtha9-Mar-10 21:22
rahul.kulshreshtha9-Mar-10 21:22 
AnswerRe: How to register an ActiveX ocx file Pin
Rajesh R Subramanian9-Mar-10 20:26
professionalRajesh R Subramanian9-Mar-10 20:26 
QuestionRe: How to register an ActiveX ocx file Pin
rahul.kulshreshtha9-Mar-10 21:15
rahul.kulshreshtha9-Mar-10 21:15 
AnswerRe: How to register an ActiveX ocx file Pin
Rajesh R Subramanian9-Mar-10 21:59
professionalRajesh R Subramanian9-Mar-10 21:59 
GeneralRe: How to register an ActiveX ocx file Pin
rahul.kulshreshtha10-Mar-10 21:56
rahul.kulshreshtha10-Mar-10 21:56 
GeneralRe: How to register an ActiveX ocx file Pin
rahul.kulshreshtha12-Mar-10 1:58
rahul.kulshreshtha12-Mar-10 1:58 
GeneralRe: How to register an ActiveX ocx file Pin
Rajesh R Subramanian12-Mar-10 5:41
professionalRajesh R Subramanian12-Mar-10 5:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.