![]() |
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Semaphore | Jaken | Shell Programming and Scripting | 2 | 04-04-2009 05:10 PM |
| Semaphore problem.... | Dreams in Blue | UNIX for Advanced & Expert Users | 1 | 05-29-2008 12:41 AM |
| Semaphore debugging | ptprabu | High Level Programming | 5 | 11-28-2007 04:09 PM |
| Semaphore | vjsony | UNIX for Dummies Questions & Answers | 3 | 04-07-2003 02:06 PM |
| semaphore | yls177 | UNIX for Dummies Questions & Answers | 1 | 10-08-2002 11:18 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
|
|
||||
|
I recommend this book,
http://www.amazon.com/exec/obidos/tg...97506?v=glance |
|
||||
|
Semaphore: Semaphore is nothing but a term used in UNIX for a variable which acts as a counter. 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 reinitializes 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. 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 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. The value of semaphore represents thus the number of threads which are nothing but processes. In other words we found that if the value is positive then we have threads to decrement and proceed for execution without suspending. If the value of semaphore is negative then it represents that the number of threads or process is blocked and kept in suspended state. If the value of semaphore is zero then it means that there are no threads or processes in waiting state. |
|
|||||
|
linuxwebmaster,
When you quote some source other source than yourself, it would be nice to give a proper attributes to the quote. |
|
||||
|
Quote:
![]() |
| Sponsored Links | ||
|
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|