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:
Anonymous2009-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.
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:
Anonymous2009-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.
>>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:
Anonymous2009-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:
Anonymous2009-12-16 7:27
1. Open every file in your system with full read/write lock.
2. ???
3. PROFIT
Name:
Anonymous2009-12-16 7:30
>>9
this made me wtf.
that's the last hobby i would expect a construction worker to have.
Name:
Anonymous2009-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:
Anonymous2009-12-16 9:03
>>12
How do you simulate a Turing-complete machine by fixing a house?