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 Advanced & Expert Users
.
google unix.com




View Single Post in the UNIX and Linux Forums - Click on the Thread or Permalink to View Entire Thread -->
  #1 (permalink)  
Old 08-28-2007
maverix maverix is offline
Registered User
  
 

Join Date: Jun 2007
Posts: 12
semaphore concept

Hi All,

I am going through the semaphore concept and have a doubt regarding the same and hope to get a resolution here.

I have a file which has a number of records.
I want to write an application (in C) which will be able to do concurrent read/write on these records.

Of what I have understood about semaphores, I know that a process can obtain a lock on the critical section of code, read/write into records, then release the lock so the other processes waiting to access the data can obtain a lock.

I am confused and tend to think that "Wouldn't this concept lead to a more serious problem?" as another process, actually wanting to read/write a different record on the same file has to wait for the lock to get released by the process which has obtained the lock. If this is the case, think of a situation where we have a large number of processes (say, more than 1000) wanting to do a read/write on same/different records. Wouldn't this concept slow down the application?

Please let me know if I have misunderstood the concept and throw some light on this...

Regards
maverix

Last edited by maverix; 08-28-2007 at 11:35 AM.. Reason: remove my name in the signature