Академический Документы
Профессиональный Документы
Культура Документы
Interrupt Latency
The following factors control interrupt latency and, therefore response.
1. Disable Time = the longest period of time during which interrupts are disabled. 2. Overhead = how long it takes the microprocessor to stop what it is doing, do the necessary bookkeeping, and start executing the first instruction of the interrupt routine.
semaphores
RTOS semaphores
Most RTOS normally use the paired terms take and release. Other RTOS paired terms may be get-give, pend-post, waitsignal. Tasks can call two RTOS functions, TakeSemaphore and ReleaseSemaphore. If one task has called Take-Semaphore to take the semaphore and has not called ReleaseSemaphore to release it, then any other task that calls TakeSemaphore will be blocked until the first task calls ReleaseSemaphore. Only one task can have the semaphore at a time.
void vRespondToButton (void) /* "Button Task" - High priority */ { !! Block until user pushes a button i = !! Get ID of button pressed TakeSemaphore (); tankdata[i].ITimeUpdated, tankdata[i].ITankLevel); ReleaseSemaphore (); } void vCalculateTankLevels (void) /* "Levels Task" - Low priority */ { TakeSemaphore (); !! Set tankdata[i].ITimeUpdated !! Set tankdata[i].ITankLevel ReleaseSemaphore (); (...) }
Semaphore Variants Counting semaphores semaphores that can be taken multiple times. Resource semaphores useful for the shared-data problem. Mutex semaphore automatically deal with the priority inversion problem.
Reentrancy
A reentrant function can be interrupted at any time and resumed at a later time without loss of data. A reentrant function can be used by more than one task without fear of data corruption. That is, more than one instance of it can be concurrently invoked and executed. One way to avoid the shared data problems is to allow access to shared data only among reentrant functions.
Deadlock
A deadlock, also called a deadly embrace, is a situation in which two tasks are each unknowingly waiting for resources held by the other.
Assume task T1 has exclusive access to resource R1 and task T2 has exclusive access to resource R2. If T1 needs exclusive access to R2 and T2 needs exclusive access to R1, neither task can continue. They are deadlocked.