Unix Programming - Semaphores Help

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > April 2004 > Semaphores Help





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Semaphores Help
Xarky

2004-04-28, 3:33 am

Hi,

Regarding the same problem (the previous one has been solved with msg
queues), where I need to write to a file. When this happens, I want
that only one process have access to the file (basically the process
requesting to write).

Should I use semaphores, so that the requested process enters a
critical section when needed and it ensures that the resource (file in
this case) is used only by the current process and is blocked for all
the others.

Or does there exist some other useful structure, that could aid me in
this problem.

I hope my question is clear, and that someone could help me.


Thanks in Advance
Barry Margolin

2004-04-28, 10:34 am

In article <bc42e1a.0404272255.3c45817b@posting.google.com>,
bernardpace@yahoo.com (Xarky) wrote:

> Hi,
>
> Regarding the same problem (the previous one has been solved with msg
> queues), where I need to write to a file. When this happens, I want
> that only one process have access to the file (basically the process
> requesting to write).
>
> Should I use semaphores, so that the requested process enters a
> critical section when needed and it ensures that the resource (file in
> this case) is used only by the current process and is blocked for all
> the others.
>
> Or does there exist some other useful structure, that could aid me in
> this problem.


Since you're trying to control access to a file, file locking seems more
appropriate.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com