Does WaitForSingleObject timeout after 49 days if INFINITE is passed?
-
We do not know how WaitForSingleObject is implemented. We are just relying on the MSDN documentation. Documentation says, if I pass INFINITE as a timeout value, the function will be blocked indefinitely until the object is signaled. But when I checked the #define value of the INFINITE, it is 0xFFFFFFFF So we pass OxFFFFFFFF to WaitForSingleObject as a timeout. It is equivalent to 49 days. So my question is, does WaitForSingleObject timeout after 49 days if INFINITE is passed. :)
Prafulla Vedante
-
We do not know how WaitForSingleObject is implemented. We are just relying on the MSDN documentation. Documentation says, if I pass INFINITE as a timeout value, the function will be blocked indefinitely until the object is signaled. But when I checked the #define value of the INFINITE, it is 0xFFFFFFFF So we pass OxFFFFFFFF to WaitForSingleObject as a timeout. It is equivalent to 49 days. So my question is, does WaitForSingleObject timeout after 49 days if INFINITE is passed. :)
Prafulla Vedante
Without testing it, I'd say it won't time out. Some value has to be used as
INFINITE
, and the maximum unsigned value is a good choice. Writing the code so that it never expires isn't difficult; it's not like something is going to wake up and decrement it every millisecond.Robust Services Core | Software Techniques for Lemmings | Articles
-
We do not know how WaitForSingleObject is implemented. We are just relying on the MSDN documentation. Documentation says, if I pass INFINITE as a timeout value, the function will be blocked indefinitely until the object is signaled. But when I checked the #define value of the INFINITE, it is 0xFFFFFFFF So we pass OxFFFFFFFF to WaitForSingleObject as a timeout. It is equivalent to 49 days. So my question is, does WaitForSingleObject timeout after 49 days if INFINITE is passed. :)
Prafulla Vedante
0xFFFF is a value which is literally NOT "passed". That is, it's something like a zero ("0") used in the BIOS that a user can select/type as input which, under advanced CPU settings for example, signals that "ALL" cores are to be used (say there are 16 cores). Which is not to say that 1, 2, 3, 4, etc cores can take zero's place in the control for the specific input value. It seems contrary to common sense use that a real value can be used to represent a ceiling or a floor as such but when it is the case, generally there's a typed message/note to the substitution next to such a control.
-
We do not know how WaitForSingleObject is implemented. We are just relying on the MSDN documentation. Documentation says, if I pass INFINITE as a timeout value, the function will be blocked indefinitely until the object is signaled. But when I checked the #define value of the INFINITE, it is 0xFFFFFFFF So we pass OxFFFFFFFF to WaitForSingleObject as a timeout. It is equivalent to 49 days. So my question is, does WaitForSingleObject timeout after 49 days if INFINITE is passed. :)
Prafulla Vedante
Quote:
But when I checked the #define value of the INFINITE, it is 0xFFFF.
Probably you meant
0xFFFFFFFF
. That said, the documentation is clear: if you passINFINITE
(0xFFFFFFFF
) then the function shall wait forever (not2^32-1
milliseconds). So it just depends on how much you trust the documentation. -
Quote:
But when I checked the #define value of the INFINITE, it is 0xFFFF.
Probably you meant
0xFFFFFFFF
. That said, the documentation is clear: if you passINFINITE
(0xFFFFFFFF
) then the function shall wait forever (not2^32-1
milliseconds). So it just depends on how much you trust the documentation.You are right 8 Fs are there as it is a 32 bit value.
Quote:
So it just depends on how much you trust the documentation. Quote Selected Text
Yes, As the api source is not open source, Is there any minor possibility of having it blocked for 49 days..... Probably we can check it by debugging the api in assembly code. I am just doubting if microsoft has passed the timeout value to the internal generic logic considering the user will never keep itself block for 49 days .... :rolleyes: :laugh:
Prafulla Vedante
-
You are right 8 Fs are there as it is a 32 bit value.
Quote:
So it just depends on how much you trust the documentation. Quote Selected Text
Yes, As the api source is not open source, Is there any minor possibility of having it blocked for 49 days..... Probably we can check it by debugging the api in assembly code. I am just doubting if microsoft has passed the timeout value to the internal generic logic considering the user will never keep itself block for 49 days .... :rolleyes: :laugh:
Prafulla Vedante
-
You are right 8 Fs are there as it is a 32 bit value.
Quote:
So it just depends on how much you trust the documentation. Quote Selected Text
Yes, As the api source is not open source, Is there any minor possibility of having it blocked for 49 days..... Probably we can check it by debugging the api in assembly code. I am just doubting if microsoft has passed the timeout value to the internal generic logic considering the user will never keep itself block for 49 days .... :rolleyes: :laugh:
Prafulla Vedante
PrafullaVedante wrote:
considering the user will never keep itself block for 49 days ....
I have. Code starts and a section of it waits for a global shutdown object to be signaled. (That aside, I believe Raymond Chen has confirmed that INFINITE really is infinite.)