Are MAXIMUM_WAIT_OBJECTS 64 Really?

MSDN says that

The maximum number of object descriptors is MAXIMUM_WAIT_OBJECTS

for WaitForMultipleObjects ... On my computer, which was defined as 64. Is it really only 64?

thanks

+6
c ++ multithreading
source share
2 answers

Yes, this is really the meaning of this macro.

Whether or not the maximum number of objects that a function can expect immediately is an internal detail of the implementation. But if I were writing this function, I would check the given length of the array to make sure that it was within the documented boundaries before continuing, even if the rest of the code would be able to wait for more, because I don’t want API consumers to use more than a documented maximum, and then rely on such undocumented behavior, thereby setting requirements for any potential function implementations in future OS releases

+5
source share

Yes, it really is 64. Since it is #define , it cannot change without recompiling programs, so it can hardly change.

Since STATUS_ABANDONED_WAIT_63 defined as 0xBF and STATUS_USER_APC is defined as 0xC0, if you increased MAXIMUM_WAIT_OBJECTS even by one, there would be no way to tell the difference between the 65th descriptor that was left and your expectation to complete APC. Correctly changing MAXIMUM_WAIT_OBJECTS will require renumbering the status codes, which will require recompiling each Win32 program.

In addition, a program compiled with MAXIMUM_WAIT_OBJECTS , defined as 65, will not work on the OS where it is defined as 64.

+14
source share

All Articles