PDA

View Full Version : WFD Error Codes Thread Safe?



lewk
07-08-2011, 03:27 PM
It seems to me that the following sequence:

Thread1:

wfdAnyFunction1( ); // Any arbitrary wfd function call
errorCode1 = wfdGetError( device );

Thread2:

wfdAnyFunction2( ); // Any arbitrary wfd function call
errorCode2 = wfdGetError( device );

is NOT thread safe when threads are using the same device.
Itís possible that the value of errorCode1 could actually belong to Thread2 or the errorCode2 value could belong to Thread1.
Am I missing something? Is the WFD client required to serialize access to the WFD driver to ensure error codes are correctly interpreted?

stevef
07-12-2011, 05:51 AM
Lewk,

The OpenWFD specification states that:

"The wfdGetError function returns the oldest error code provided by an API call on device since the previous call to wfdGetError on that device", and also "After the call, the error code is cleared to 0"

This is similar to other Khronos standards in that only the oldest error is stored and the error is reset when read. Where the OpenWF APIs depart from the previous Khronos standards is that the error code (and other object data) is intended to be stored in process storage versus thread local storage. In other words, there is only one error code for the object versus one error code per thread interacting with the API. As I recall this was done deliberately with the desire to prevent some of the issues that occur when a thread maintains the state of an interaction with the API.

In any case, I'm not sure this is a thread safety issue as much as a single process-wide error code handling issue. I see your point, though. Hopefully you will see that the benefits of process-wide object data when abstracting a single purpose hardware block out-weights the occasional nuisance of a common error code.

Steve.

lewk
07-12-2011, 09:04 AM
Hi Steve:

Thanks for your reply.
I suppose there was a reason for not doing it but if functions returned WFDErrorCode directly the error code problem could be avoided.

lewk