On 17Oct2007 16:36, mukyvelous2k5 <[EMAIL PROTECTED]> wrote:
| When 2 processes are running and both of them wants to update a 
| certain database. Say if process A is running (it is now locked) and 
| along the line, it crashes. Then process B will never run. How do i 
| solve this problem.

It is bad form to ask other people to do your homework for you. You
learn less, because knowledge you don't figure out for yourself does not
stick in you mind as well.

On UNIX, you could use a lock that is tied to the file handle. When the
program crashes the OS closes the file handle, releasing the lock.

You could do the locking from outside the program with a wrapper that
goes: take lock, run program, release lock. I do that fairly often.

You could use some mechanism that checks the validity of the lock.
Instead of holding the lock itself for the duration of the program,
you take a lock on something else. Program A takes the lock, checks a
status file to see if another program is active. If so, it releases
the lock and retries later. If not, it updates the status file to
describe itself (eg by writing it's process id into the status file),
and _then_ releases the lock. Program B does the same. If the status is
a process id, you can see it that's running on the current machine with
"kill -0 the-process-id".

These are all just possibilities.
-- 
Cameron Simpson <[EMAIL PROTECTED]> DoD#743
http://www.cskk.ezoshosting.com/cs/

Applications Programming is for dullards who can't do Systems Programming.
        - David Rose, [EMAIL PROTECTED]


To unsubscribe from this list, please email [EMAIL PROTECTED] & you will be 
removed. 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/LINUX_Newbies/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/LINUX_Newbies/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 

Reply via email to