Internals

Task Synchronization

Task Synchronization is achieved through the use of locks. Without locks, two tasks might simulatenously modify the locked elements. Locks are stored in a global array of size NUM_LOCKS. To prevent preemption during the lock (if we don't disable preemption, then we have the same problem with the lock as with task synchronization, that two tasks might modify the lock at the same time) we disable interrupts, reenabling them when we leave the lock. While a task cannot obtain a lock, it busy waits until the task holding the lock first unlocks it. The user should be aware that potential for deadlock exists if locks are not used carefully. Unlock is used to release a lock, however it does not require disabling interrupts since the operation does not need to be atomic. If NUM_LOCKS is set to 0, then support for locks is not programmed into flash in order to save space since they are not being used.