Where is the semaphore stored in UNIX operating system?
Before going into the storage of semaphore it is first vital to know about semaphores. A semaphore is nothing but a term used in UNIX for a variable which acts as a counter. So the next question that comes in mind is what for we need this variable. It’s so simple. The reason is explained below. For instance there may be times when two processes try to access the same file simultaneously. In this event we must control the access of the file when the other process is accessing. This is done by assigning value to semaphore. The value of the semaphore is initialized by the first process when the file is in access by it. When the second process try to access the file it checks the value of the semaphore and if it finds the value as initialized it does not access the file. After the first process is completed it re initializes the semaphore value and now the second process uses it. The above example is for two processes but a semaphore can be used even when numbers of processes try to access the same file. Thus semaphores are used to coordinate access to a resource by different processes. Thus we have seen that semaphore can be used when numbers of processes try to access the same file. In this case we must make the semaphore available or accessible to all processes so that they can read and check the value and also initialize and reinitialize the value of semaphore appropriately. For this reason only the semaphore is stored in kernel so that it can be accessed by all processes.
So the semaphores are stored in kernel in UNIX operating system.
Questions by GeekAdmin answers by GeekAdmin
Showing Answers 1 - 2 of 2 Answers
Related Answered Questions
Related Open Questions
Where is the semaphore stored in UNIX operating system?
So the semaphores are stored in kernel in UNIX operating system.
Profile Answers by GeekAdmin Questions by GeekAdmin
Questions by GeekAdmin answers by GeekAdmin
Related Answered Questions
Related Open Questions