Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

File Locking

Name: Anonymous 2009-12-16 0:24

I have a bit of a problem wrapping my head around some of it.

All examples I see, have you use an exclusive file lock when writing.

And a shared file lock when reading.

What happens if I don't use a shared file lock if I'm only reading a file?

Name: Anonymous 2009-12-16 0:30

Undefined behavior if someone else writes at the same time if you don't use a lock at all, or asshole behavior on your part if someone else tries to read at the same time if you use an exclusive lock.

Name: Anonymous 2009-12-16 0:33

That was a hard one. For your next question, ask what the difference between a thread and a process is and we can all be in high school again.

Name: Anonymous 2009-12-16 0:33

Really?

Okay. Reading doesn't alter data, so shared locks are cool here no problems arise from multiple readers.

Writing does alter the data. If you don't get an exclusive lock then you can get corrupt data in the file, or at least into a reader.

A lot of locks are purely voluntary, so um, yeah. Don't assume anything outside your app is going to play by the rules, unless you know you're in an environment where obeying the locking facility you have chosen is enforced.

I'm sure wikipedia has something interesting to say on the matter: http://en.wikipedia.org/wiki/File_locking but I can't be arsed to read it.

Name: Anonymous 2009-12-16 0:47

>>3
Yeah, because everybody in /prog/ is a working ENTERPRISE programmer.

No wait, you actually think the only people who should be allowed to post here are those kinds of persons.

Name: Haxus the Artist 2009-12-16 1:25

/prog/tip: If you ever find yourself in a situation where file locking seems like a good idea, you should seriously reconsider your design.

Name: Anonymous 2009-12-16 2:28

>>5
/prog/ is not /helpmewithmyhighschoolhomework/. You're looking for /pr/.

Name: Anonymous 2009-12-16 2:35

>>5
You're an idiot. What the locks do is right there in the name. It doesn't take a huge amount of experience to read.

Name: Anonymous 2009-12-16 5:12

>>5
I program mostly as a hobby. I make a living from restoring and fixing up old houses, especially plaster.

Name: Anonymous 2009-12-16 7:27

1. Open every file in your system with full read/write lock.
2. ???
3. PROFIT

Name: Anonymous 2009-12-16 7:30

>>9
this made me wtf.
that's the last hobby i would expect a construction worker to have.

Name: Anonymous 2009-12-16 8:02

>>11
Why? Fixing old houses, especially plaster, is very similar to programming, except that you can do the latter while sitting in a comfortable chair, not being covered with plaster dust etc.

Name: Anonymous 2009-12-16 9:03

>>12
How do you simulate a Turing-complete machine by fixing a house?

Name: Anonymous 2009-12-16 9:34

>>13
You don't.

Name: Anonymous 2009-12-16 9:41

>>13
I did this by buying a house next to a theoretically infinite river and some ducks.

Name: Anonymous 2009-12-16 10:06

>>15
if you lived next to a river, would it be legal to kill and eat the ducks inhabiting it?

Name: Anonymous 2009-12-16 10:07

LOCK MY ANUS

Name: Anonymous 2009-12-16 11:59

This thread had been semaphored.  You can't reply to it right now.

Name: Anonymous 2009-12-16 12:56

>>18
V()

Name: Anonymous 2009-12-16 13:27

>>19
Exception in thread “1260941086”
 prog.util.ConcurrentModificationException

Name: Anonymous 2010-12-06 9:54

Back to /b/, ``GNAA Faggot''

Name: Anonymous 2013-09-01 20:41



                   ,.-‐、.  ,.-‐、    , " ̄ ヽ.
    .  。           /  / /  /   i     i
           *       | /____| /     ヽ、.,__,ノ
        ゜        ,.''-'  └'`ヽ.     。
       .        /        / ハ         .
      .....         .i       レ'k'      *
....:::::::::::::  ___r、         | i      | |,!    __,,..-‐rr'^ー-、
::::::::::::::::: ヽ、___7´`'ー- 、..,___| |    i |ヘ-‐''"´:::::::::::::::| |__,,.ノ
::::::::::::::::::::::   └- 、::;;;_::::::::::| |  i   | |:::::__;;;;:::: --─┘'
:: :: :: :: :: :: :: :: :: ::     ̄ `'| |  |.  | |Y´   :: :: :: :: :: :: :: ::
: : : : : : : : : :    | /|  ハ  | /::|   : : : : : : : :
                レ' 7V::::ヽ/::::::::|    、ヽ川 l | 川 l |
                 くァ-r─r--、」    ミ
                /  /  i  ',    三  戻 早
               /  /   l   i    .Ξ   っ く
              ヽ、r-'、.,______」____,.」    三  て 地
               /  ./` ̄|  |      Ξ  こ 球
               /  /    |  |     三.  い に
               ,'  /    |  |     Ξ  ! !
             /、__/    |___,.|      彡
            ,イ'ー‐'!    iー-‐i      ン川 l | 川 l |
            l::::::::/i     |:::::::::i〉
---─ァ=ニニ二"´ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄ ̄``二ニニ=ァ‐---

Don't change these.
Name: Email:
Entire Thread Thread List