View previous topic :: View next topic |
Author |
Message |
star99 Beginner
Joined: 09 Mar 2004 Posts: 4 Topics: 2
|
Posted: Tue Mar 09, 2004 2:30 pm Post subject: how can a programmer avoid deadlocks in cics ? |
|
|
is it his/her responsibility ? |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Tue Mar 09, 2004 3:13 pm Post subject: |
|
|
Star99,
I can say to some extent it is indeed the programmer's responsibility to avoid dead locks. First take a look as to why the dead lock has occured in the first place. once you know the reason/culprit , then it is a simple task of how to handle the deadlock. If the transaction is not that critical , code a delay in the pgm and try the update after the delay. If this task is indeed critical , then you need to check with the other task and see if then can implement the delay logic. If you are dealing with DB2 the check the isolation level defined.
Hope this helps...
Cheers
Kolusu _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
star99 Beginner
Joined: 09 Mar 2004 Posts: 4 Topics: 2
|
Posted: Tue Mar 09, 2004 4:56 pm Post subject: |
|
|
sorry, but i wondered how can the programmer avoid dead locks before it happens ? |
|
Back to top |
|
|
R.Nickel Beginner
Joined: 02 Dec 2002 Posts: 22 Topics: 0 Location: Sydney, Australia
|
Posted: Tue Mar 09, 2004 10:39 pm Post subject: |
|
|
Deadlocks occur because 2 programs are updating 2 or more databases, if program PGM1 updates DB1 and DB2 in that order and program PGM2 updates DB2 then DB1 then you have a potential for a Deadlock. ensuring that this does not happen will ensure that you have no deadlocks and the subsequent deadlock ABEND _________________ Rainer |
|
Back to top |
|
|
Mike Chantrey Intermediate
Joined: 10 Sep 2003 Posts: 234 Topics: 1 Location: Wansford
|
Posted: Mon Mar 15, 2004 8:32 am Post subject: |
|
|
To expand/generalize the above comment, the general principle for avoiding deadlocks is:
"All programs which update more than one recoverable resource should update in the same order."
Why? If program A updates item X then Y, and program B updates Y then X, you can get a situation where A holds X and needs Y, and B holds Y but needs X. Neither can proceed - deadlock occurs.
This cannot occur if they both update X then Y.
Thje recoverable resources could be records on the same file/table or different files/tables. Applies to VSAM, DB2 whatever. |
|
Back to top |
|
|
|
|