Click here to Skip to main content
15,891,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Dynamic Menu Creation Pin
Thakur JAI SINGH25-Feb-15 0:30
Thakur JAI SINGH25-Feb-15 0:30 
GeneralRe: Dynamic Menu Creation Pin
_Flaviu25-Feb-15 0:45
_Flaviu25-Feb-15 0:45 
GeneralRe: Dynamic Menu Creation Pin
Thakur JAI SINGH25-Feb-15 2:09
Thakur JAI SINGH25-Feb-15 2:09 
GeneralRe: Dynamic Menu Creation Pin
Frankie-C25-Feb-15 3:06
Frankie-C25-Feb-15 3:06 
QuestionRe: Dynamic Menu Creation Pin
David Crow25-Feb-15 5:53
David Crow25-Feb-15 5:53 
QuestionSetEvent and WaitForSiongleObject Pin
Munchies_Matt23-Feb-15 6:02
Munchies_Matt23-Feb-15 6:02 
AnswerRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin23-Feb-15 9:45
professionalAlbert Holguin23-Feb-15 9:45 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt23-Feb-15 21:26
Munchies_Matt23-Feb-15 21:26 
Event created thus:
WriteTrigger = CreateEvent(NULL, FALSE, FALSE, "arse");


This is the write thread (yeah, its MFC):

C++
AFX_MANAGE_STATE(AfxGetStaticModuleState());

while(pDlg->Go)
{
    if(!WriteFile(gh, buf, towrite, &written, 0))
    {
        pDlg->doerror();
    }
    WaitForSingleObject(pDlg->WriteTrigger, INFINITE);
}



Here is the read thread:
C++
    AFX_MANAGE_STATE(AfxGetStaticModuleState());

while(pDlg->Go)
{
    ReadFile(gh, buf, 1024 - readTot, &read, 0);

            ... process data, snipped

    WriteFile(gh, &ACK, 1, &written, 0);

    SetEvent(pDlg->WriteTrigger);
    }



As you can see, its very very simple and I cant see any reason for the often massive delays. As I said, my driver traces the incoming reads and writes off the app aswell, and it confirms that the delay is in usermode.



Albert Holguin wrote:
If this were true, there would be A LOT of very slow programs out there....


Er, ever used Windows 7? Wink | ;)

Seriously though, I have been writing Windows kernel drivers, and using MFC to write test apps, and utilities for that entire time too. I have written all sorts of threaded code in the Kernel, and never seen any delays like this using KeWaitforSingleObject and KeSetEvent.

It just looks like really crap user mode thread scheduling (this is win 7 64, the app is win32).
GeneralRe: SetEvent and WaitForSiongleObject Pin
Jochen Arndt23-Feb-15 23:10
professionalJochen Arndt23-Feb-15 23:10 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 0:02
Munchies_Matt24-Feb-15 0:02 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 3:54
professionalAlbert Holguin24-Feb-15 3:54 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 4:02
Munchies_Matt24-Feb-15 4:02 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 4:06
professionalAlbert Holguin24-Feb-15 4:06 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 4:13
Munchies_Matt24-Feb-15 4:13 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 4:16
professionalAlbert Holguin24-Feb-15 4:16 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 5:13
Munchies_Matt24-Feb-15 5:13 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt23-Feb-15 22:25
Munchies_Matt23-Feb-15 22:25 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Albert Holguin24-Feb-15 4:00
professionalAlbert Holguin24-Feb-15 4:00 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 4:12
Munchies_Matt24-Feb-15 4:12 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Frankie-C24-Feb-15 5:19
Frankie-C24-Feb-15 5:19 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 6:46
Munchies_Matt24-Feb-15 6:46 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Frankie-C24-Feb-15 21:46
Frankie-C24-Feb-15 21:46 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 22:12
Munchies_Matt24-Feb-15 22:12 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Frankie-C24-Feb-15 22:49
Frankie-C24-Feb-15 22:49 
GeneralRe: SetEvent and WaitForSiongleObject Pin
Munchies_Matt24-Feb-15 22:57
Munchies_Matt24-Feb-15 22:57 

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.