A task that is currently holding a unsharable resource is said to be in critical section associated with that resource.
- Locking the resource mainly achieved by means of Binary Semaphores.
- When a task wants to enter a critical section, it first checks whether the corresponding semaphore is taken or not. If the semaphore is locked,then the task will wait until the semaphore is unlocked.
- Critical Sections are always properly nested Lock R1; Lock R2; Unlock R2; unlock R1.Where R1 and R2 are two resources.
Sharing a resource always leads to Priority Inversion Problem, that a high priority task is waiting to run under a CPU, whereas the low priority tasks are running locking a resource.