Re: flock or IPC semaphore for atomic appends

From: A. Sinan Unur (asu1_at_c-o-r-n-e-l-l.edu)
Date: 11/14/03


Date: 14 Nov 2003 15:22:13 GMT

adwser@hotmail.com (jtd) wrote in
news:c57c103.0311140015.7052583b@posting.google.com:

> 2) Why is flock processor intensive? Does flock write something to
> disk when locking/unlocking?

>From perldoc -f flock:

Two potentially non-obvious but traditional "flock" semantics
are that it waits indefinitely until the lock is granted, and
that its locks merely advisory.

I haven't looked at the source, but I think it is this waiting indefinitely
part (polling?) that's causing CPU usage to go up.

Sinan.

-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


Relevant Pages

  • flock affects local node only traditionally and applications expect
    ... that flock used to work over the network (since it used to be mapped ... have apps that would benefit from local file lock semantics over the network ... The client VFS has to be ...
    (Linux-Kernel)
  • Re: Trying to understand flock()
    ... > (thus forcing the program to use flock() rather then fcntlfor file ... > semantics of flockthat I don't understand. ... > lock_exclusive (register int const fd) ... in multiple instances of a lock, but rather multiple references to the ...
    (freebsd-questions)
  • Re: I cant flock, it returns 0, any ideas.
    ... > I can't flock, it returns 0, any ideas. ... You can only hold a lock on an open file. ... will fail but attempts to get another LOCK_SH lock will ... this is not how you pause the script! ...
    (comp.lang.perl.misc)
  • Re: I cant flock, it returns 0, any ideas.
    ... # returns zero when I try to flock ... >> I wanted to run this script to see if it would affect my other perl ... If someone holds a LOCK_EX lock, all attempts to get a lock will ... > the flock call will fail, and if you don't flock will just not ...
    (comp.lang.perl.misc)
  • Re: UW imap-2006b: 64 bit problem
    ... UW imapd is obliged> to do considerable more work on SVR4 systems than it does on BSD and> Linux systems which offer flock() locking as an alternative to POSIX> locking. ... IEEE Std 1003.1-1988 requires that all fcntl() locks associated with a file for a given process are removed when *any* file descriptor for that file is closed by that process. ... Put another way, before any library routine opens a file, it must be aware of what files the application and any other libraries have open and locked; otherwise the library routine will remove the lock unexpectedly when it closes the file. ...
    (comp.mail.imap)