Home |
RTKernel-32 Programming Manual Multitasking, Real-Time, and RTKernel-32 Alternate APIs for RTKernel-32 Deadlock |
DeadlockThe term deadlock denotes the mutual blocking of several tasks. The mutual exclusion algorithm entails the danger of a deadlock. Assume that access to a global data object shall be protected using a semaphore. For this purpose, a semaphore is initialized with 1 event. If the mutual exclusion protocol is used, two typical errors can occur: Case 1A task "forgets" the call to RTKSignal after accessing the data. All other tasks that want to access the data are blocked as soon as they try to access the data. The erroneous task will block itself forever, too, if it again tries to get at the data using a call to RTKWait. Case 2The task calls RTKWait twice. Even if two calls to RTKSignal follow, the task has blocked itself and all other tasks requiring access to the data forever. In both cases, using resource semaphores and RTKernel-32's Debug Version would lead to error messages, since the rules for using resource semaphores are violated. The only unambiguous deadlock situation RTKernel-32 can recognize arises when a task terminates that is expected to receive data from an RTKSend operation by another task. The sending task will enter the state TS_DEADLOCKED.
|