|
Hi Jim and Neo,
Thank you for your replies...
I am using RHEL 4.
I have used lockf() and flock() system calls and it seems to work fine.
However, I want to use semaphores to get the same effect. FYI...I am doing these just to understand and learn the concepts. Its not a live/industry project.
Using lockf() and flock(), I was able to lock certain sections of files depending on the file position we provide. Say, for example, the application is a simple banking application and the database I use is a simple file which has number of records which contains account information. Using lockf(), I was able to lock a certain record by obtaining the account number from the user so that another process wanting to access a different record didn't have any issues in reading/writing to a different record.
My question was how to get the same effect using semaphores. If the number of concurrent processes are more, then each process will be waiting to obtain the semaphore to enter the critical section of code, isn't that so?
regards
maverix
|