MsgWaitForMultipleObjectsEx

The arguments to the functions are:

nCount [in]

The maximum number of object handles is MAXIMUM_WAIT_OBJECTS minus one.

pHandles [in]

The array can contain handles to multiple types of objects. It may not contain multiple copies of the same handle.

If one of these handles is closed while the wait is still pending, the function’s behavior is undefined.

dwMilliseconds

The function either waits for dwMilliseconds or until the object values

dwWakeMask [in]

The input types for which an input event object handle will be added to the array of object handles. T

Concept:

Let us assume that we have a thread named as ‘thread1’. The thread does some task and needs two values for further proceedings. Let the value required by this thread be processed by another two threads, say named as ‘threadN’ and ‘threadN+1’. Now thread1 has to wait until the values required [ Eg: Object A and Object B ] are filled by threads ‘threadN’ and ‘threadN+1’.

By using MsgWaitForMultipleObjectsEx, we can achieve this. This function makes the execution wait until the objects A and B are received /filled. If values are not filled within ‘dwMilliseconds’, the wait for object stops and the execution continues sequentially.

We can think of  MsgWaitForMultipleObjectsEx as an asynchronous mechanism. let us consider a scenario where we have a UI thread and logic processing thread, executing concurrently. Then we can display a busy icon in the UI until the logic thread manipulates the data values to be rendered on the UI. In this situation we can assume that the function MsgWaitForMultipleObjectsEx is placed in logic thread and it is waiting for threadN and threadN+1 to supply values in Objects A and B, The communication between the UI component and the logic procesing unit can occur asynchronusly. Wehn value is obtained from threadN and threadN+1 , the waiting process terminates and the object values can be rendered on UI.

Video memory

Video memory is the memory area corresponding to the monitor i.e what is written on the video memory is displayed on the monitor. The example that I would like to illustrate is a little old fashioned and workable in DOS O.S.

char far *scr = 0xb8000000;

main()

{

int i,j;

for(i=0; i < 2000; i++)

for(j=0; j < 2000 ; j++)

*(scr + (2000 * i ) + )  = ‘A’;

}//end

I just wanted to display ‘A’ all over screen which other wise would have done using printf ( any inbuilt function) also. The time difference noticed while executing the program using print and using video memory access method is astonishing. By directly writing on the video memory we by pass 2000 X 2000 function call and the efficiency is remarkable.

regarding the pointer details – as we know intel architecture fllows segment memory model. memory is divided into Code Segment, Data Segment, Extra Segment, Stack Segment. A usual pointer such as int *ptr can point only within data /extra segment. To point to a location outside this segment we have to use far pointer.