Home |
RTKernel-32 Programming Manual Multitasking, Real-Time, and RTKernel-32 Alternate APIs for RTKernel-32 RTKernel-C 4.5 for DOS Compatible API Win32 and RTKernel-32 Error Handling Mixing RTKernel-32 and Win32 APIs Function InitializeCriticalSection Function InitializeCriticalSectionAndSpinCount Function TryEnterCriticalSection Function DeleteCriticalSection Function WaitForMultipleObjects Function QueryPerformanceCounter Function QueryPerformanceFrequency Function GetSystemTimeAdjustment Function SetThreadAffinityMask Function SetThreadGroupAffinity |
Win32 and RTKernel-32 Error HandlingRTKernel-32's Win32 emulation is implemented by a set of Win32-compatible functions which reformat the given parameters and then call equivalent RTKernel-32 functions. One area difficult to translate is the different error-handling philosophy of the two systems. When a Win32 function fails, a return value indicating error is returned and the application must check for any errors by calls to GetLastError after each single Win32 call. This method can severely increase code size and reduce readability. RTKernel-32, on the other hand, will not pass fatal errors to the application, but rather abort the application. This method is adequate since program bugs cannot be corrected dynamically at run time anyway. Rather, it is desirable to get a clear error message with all relevant information (address of call, names of tasks, semaphores, or mailboxes involved, etc.). Software debugging is significantly simplified in this way. RTKernel-32's Win32 emulation makes every effort to check all parameters at run-time to emulate Win32's error handling. SetLastError is called whenever possible. However, there may be cases where not all application bugs are caught (e.g., when the application has corrupted RTKernel-32's internal data structures). In these rare instances, an RTKernel-32 error message could be issued when Win32 would indicate the error with a return code instead. Mixing RTKernel-32 and Win32 APIs
|