Which code should the thread in App2 include?

You develop two applications named App1 and APP2. App1 writes to a buffer. You create a function named ProcessMyData. You need to ensure that App2 executes a specific thread only when the buffer is full. Which code should the thread in App2 include?

You develop two applications named App1 and APP2. App1 writes to a buffer. You create a function named ProcessMyData. You need to ensure that App2 executes a specific thread only when the buffer is full. Which code should the thread in App2 include?

A.
CRITICAL_SECTION cs;InitializeCriticalSection(&cs);While (1){ EnterCriticalSection(&cs); ProcessMyData(); LeaveCriticalSection(&cs);}

B.
HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);While (1){ WaitForSingleObject(hEvent, INFINITE); ProcessMyData();}

C.
HANDLE hEvent = CreateMutex(NULL, FALSE, FALSE, NULL);while (1){ WaitForSingleObject(hEvent, INFINITE); ProcessMyData();}

D.
HANDLE hEvent = CreateEvent(NULL, FALSE, FALSE, _T(“SyncEvent”));while (1){ WaitForSingleObject(hEvent, INFINITE); ProcessMyData();}



Leave a Reply 0

Your email address will not be published. Required fields are marked *