[clug] Semaphores and shared memory
Martin Pool
mbp at sourcefrog.net
Wed Dec 10 04:02:15 GMT 2003
On 10 Dec 2003, Jepri <jepri at webone.com.au> wrote:
> Would that work when I'm reading and writing to the file at the same
> time (through mmaped memory)?
Yes.
> And what's the performance hit like?
It's very quick: there is one system call to lock and unlock. None of
the other approaches such as sysvsems will be faster. Unless your
application design is extremely tightly tuned the overhead of locking
will not even show up.
Presumably each process needs exclusive access to the file while it's
updating it? In that case, just lock the whole thing. If you want to
allow different processes to write different parts concurrently, lock
the relevant bits.
--
Martin
linux.conf.au -- Adelaide, January 2004
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.samba.org/archive/linux/attachments/20031210/32e7b251/attachment.bin
More information about the linux
mailing list