MainframeSupports
tip week 32/2001:

Some times it happens, that two jobs are executed in parallel, but they don't like it. This happens occasionally when two jobs updates the same DB2-table at the same time. Then perhaps they deadlock. You can avoid such a situation very easily and that is what this tip is all about.

When a dataset is used with DISP=OLD instead of DISP=SHR no one else can use this dataset at the same time. A job using a dataset with DISP=OLD will first start executing when all others are finished using the dataset. First when the last step using the dataset with DISP=OLD finishes, others may use the dataset again. Others in this case are all executing tasks in the same sysplex (not just the MVS executing the job) including other jobs, tso users and started tasks.

You can avoid two jobs from executing at the same time simply by letting them both use the same dataset with DISP=OLD. And the best way of doing this is by letting them use a dataset especially allocated for this purpose. This is much better than using an existing dataset, that may be used for other purposes. Actually you can allocate datasets, that only keep up space in the catalogs and therefore cannot contain any data. Yu can use the following step to allocate such a dataset:

//DSNTIAUL EXEC PGM=IEFBR14
//DUMMYDSN DD DSN=MY.DISP.OLD.DATASET,DISP=(MOD,CATLG,CATLG),
              UNIT=SYSALLDA,SPACE=(TRK,0)

The step allocates dataset MY.DISP.OLD.DATASET, and if it already exists nothing happens. Now the two jobs, that you want to prevent from running in parallel can use the dataset. All you have to do is add the followind DD-card to the JCL of the two jobs in a convenient place:

//DUMMYDSN DD DSN=MY.DISP.OLD.DATASET,DISP=OLD

No programming or other stuff is needed to make this trick work, and it works no matter what the problem is that causes them to work badly when they run in parallel. They will not do so any more. It is important to notice, that this technique does not control what sequence the two (or more) jobs are executed in.

Previous tip in english        Sidste danske tip        Tip list