D
Duke of Hazard
It is imperative that a section of my code is only executed by only
one user at a time. So I have my program write a lock file when it
reaches that section , then remove the lock file after it completes
that section.
This seemed to work ok, until I knew about race conditions. So I
changed the code to write the lock file twice. First at the beginning
of the script and second when it reaches the critical section of code
that must be executed by only 1 user at a time.
I figure this will significantly lower my probability of a race
condition since two race conditions will need to occur simultaneously
for it to break (which I am fine with, as long as it happens less than
once per 1000 times).
Is that right, or am I missing something?
Thanks!
one user at a time. So I have my program write a lock file when it
reaches that section , then remove the lock file after it completes
that section.
This seemed to work ok, until I knew about race conditions. So I
changed the code to write the lock file twice. First at the beginning
of the script and second when it reaches the critical section of code
that must be executed by only 1 user at a time.
I figure this will significantly lower my probability of a race
condition since two race conditions will need to occur simultaneously
for it to break (which I am fine with, as long as it happens less than
once per 1000 times).
Is that right, or am I missing something?
Thanks!