Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is MAXIMUM_WAIT_OBJECTS really 64?

MSDN says that

The maximum number of object handles is MAXIMUM_WAIT_OBJECTS

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

thanks

like image 664
Jake Avatar asked Feb 27 '11 06:02

Jake


2 Answers

Yes, it's really 64. Since it's a #define, it can't change without recompiling programs, so it pretty much can never change.

Since STATUS_ABANDONED_WAIT_63 is defined as 0xBF and STATUS_USER_APC is defined as 0xC0, if you incremented MAXIMUM_WAIT_OBJECTS by even just one, there would be no way to tell the difference between the 65th handle being abandoned and your wait being terminated by an APC. Properly changing MAXIMUM_WAIT_OBJECTS would require renumbering the status codes, which would require recompiling every Win32 program in existence.

Also, a program compiled with MAXIMUM_WAIT_OBJECTS defined as 65 would fail on an OS where it's defined as 64.

like image 128
Gabe Avatar answered Nov 05 '22 21:11

Gabe


Yes, that's really the value of that macro.

Whether that's really the maximum number of objects that the function is capable of waiting on at once is an internal implementation detail. But if I were writing that function, I'd check the given array length to make sure it was within the documented bounds before proceeding, even if the rest of the code happened to be capable of waiting for more, because I wouldn't want consumers of the API to use more than the documented maximum and then come to rely on such undocumented behavior, thus placing requirements on any potential implementations of the function in future releases of the OS

like image 10
Rob Kennedy Avatar answered Nov 05 '22 19:11

Rob Kennedy