The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-13-2004
raguramtgr raguramtgr is offline
Registered User
  
 

Join Date: Jan 2004
Location: chennai, india
Posts: 47
semaphore

what is semaphore? can any body explain it in a more simple way than the manual ??

replies appreciated

Regards
raguram R
  #3 (permalink)  
Old 07-13-2004
Tux Tux is offline
Registered User
  
 

Join Date: May 2003
Location: UK, Up North
Posts: 113
I recommend this book,
http://www.amazon.com/exec/obidos/tg...97506?v=glance
  #4 (permalink)  
Old 07-27-2004
shrikrishna's Avatar
shrikrishna shrikrishna is offline
Registered User
  
 

Join Date: Jul 2004
Location: INDIA (pune)
Posts: 7
Ce this book

hi friend jst check out it in
OS concepts by
Galvin
  #5 (permalink)  
Old 06-09-2009
linuxwebmaster linuxwebmaster is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 2
Post Semaphore

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.
  #6 (permalink)  
Old 06-09-2009
vgersh99's Avatar
vgersh99 vgersh99 is online now Forum Staff  
Moderator
  
 

Join Date: Feb 2005
Location: Boston, MA
Posts: 5,116
linuxwebmaster,
When you quote some source other source than yourself, it would be nice to give a proper attributes to the quote.
  #7 (permalink)  
Old 06-14-2009
linuxwebmaster linuxwebmaster is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 2
Question Hello

Quote:
Originally Posted by vgersh99 View Post
linuxwebmaster,
When you quote some source other source than yourself, it would be nice to give a proper attributes to the quote.
Hi Mod, I'm sorry but I didn't catch u....????
Sponsored Links
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -4. The time now is 05:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language translation by Google.
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0