written 3.6 years ago by |
MUTEX (Mutual Exclusion):
Say a resource or a semaphore is required by a task, and it gets the access of the same. If it calls another task which also requires the same resource, it will now get stuck as it is already acquired by the previous task. This is called as mutual exclusion. To resolve this a special type of semaphore called as MUTEX is used. In this case there is an additional information specifying that the semaphore is acquired by one main task and another counter keeps on incrementing, when a subtask uses it. When a subtask completes the use of the resource and decrements the count, it doesn't release the semaphore if the count is not zero.
Lock( ):
A process using the lock function enters a critical section, locks the resources to a critical section till the end of the section, and finally unlock function is used. A wait loop is said to be created when the lock( ) is executed and the wait loop ends on execution of the unlock( ). The lock ( ) and unlock( ) require little overhead. The disadvantage of this system is that the resources once locked may not be available for other tasks of higher priorities until the task executes the unlock( ).
Spinlock( ):
In case a task, say t1 is running and little time is left for its execution. If another task, say t2 uses the lock function, then the earlier task t1 will have to wait for a long time to complete its last small part of execution. In such cases the spinlock( ) function is an innovative solution. The scheduler locking processor for a task waits to cause the blocking of the running task first for a time-interval t, then for (t - δt), then (t - 2δt) and so on. When this time interval spin downs to 0, the task that requested the lock of the processor now unlocks the running task and blocks it from further running. The request is now granted. Thus a spin lock does not let a running task be blocked instantly. First successively tries decreasing the trial periods before finally blocking a task.