one of those bad weekends.. file locking by processes
Hello Ppl,
Ever get one of those days when though u've been programming for over an year, you still occasionally end up doing something utterly dumb.. but come out of it learning something new.. ok, here's my rant:
I have two variants of a genetic algorithms program I've been working on, the makefile is pretty much the same. (Using RHLinux 8.0)
For file 1_GA.c
gcc -o ga 1_GA.c -lm
------
For file 2_GA.c
gcc -o ga 2_GA.c -lm
I always started both these programs at the same time, needed to study their outputs. And the results for 2_GA.c always were totally off-mark.. my program design was correct, no logical errors, no coding faults but o/p just wasn't rite. For those who know GA's, there wasn't any convergence for 2_GA.c
So, here I was, spending over 2 days with ddd, going over 5000 lines of code... till about half an hour ago. My problem - I was compiling both programs (the compilation took around 3 minutes) into the same executable - ga!! I change the name, (or run them one by one).. EUREKA!! runs fine!
So, anyway, my question: (about time I asked it too) - what happens in the above sorta situation, which process gets to lock the file and write? which starves? do both write??
Also is there any way I can check what files are being read/written by a process?
Thanx for reading this far, hope someone can answer.. laterz