PROCEDURE dfm$shareit, shareit (
 writers, w: integer 0 .. 8 = 2
 readers, r: integer 0 .. 8 = 2
 total_minutes, tm: integer = 20
 wait_milliseconds, wm: integer =  50
 file_size, fs: integer = 204800
 establish_condition_handler, ech: boolean = true
 save_print, sp: boolean = false
 create_new_file, cnf: boolean = true
 family_name, fn: name = TESTING
 user, u: name = EVAL
 password, pw: (SECURE) name = EVALPW
 access_modes, access_mode, am: (BY_NAME) list of key all, (append, a), ..
        (execute, e), (modify, m), (read, r), (shorten, s), (write, w), ..
        keyend = all
 share_modes, share_mode, sm: (BY_NAME) list of key all, none, (append, a), ..
        (execute, e), (modify, m), (read, r), (shorten, s), (write, w), ..
        keyend = all
 status)

 " This test submits multiple jobs that share a permanent file.
" Each job writes a particular words of the file
" Jobs are also submitted that read the permanent file

  family_string = $string($value(family_name))
  user_string = $string($value(user))
  password_string = $string(password)
  handler = $strrep($value(establish_condition_handler))
  save_output = $strrep($value(save_print))
      crev ignore status
  page_count = file_size/4096
  IF create_new_file THEN
    delete_file $fname(':'//family_string//'.'//user_string//'.share.1') status=ignore
    create_file $fname(':'//family_string//'.'//user_string//'.share.1')
    detach_file $fname(':'//family_string//'.'//user_string//'.share.1')
  IFEND

  FOR i = 1 to writers DO
    colt $local.j1   until='      END_JOB' sm='?'
      LOGIN USER=?user_string? PASSWORD=?password_string? FN=?family_string?
       IF ?handler? THEN
         WHEN any_fault do
           reqoa ' WRITE?$strrep(i)? failed  '//$condition_name(osv$status.condition)
           display_value osv$status
           logout
         WHENEND
       IFEND

      attach_file $user.share.1 am=?$parameter(access_modes)? sm=?$parameter(share_modes)? lfn=share
      exet sp=dfp$test_file_sharing ..
  p='lfn=share, owr=?$strrep(i)?,tm=?$strrep(tm)?,wm=?$strrep(wm)?,pc=?$strrep(page_count)?'
       IF NOT ?save_output? THEN
         terp output
      IFEND
      LOGOUT
      END_JOB
    submit_job $local.j1 user_job_name=$name('WRITE'//$strrep(i))
  FOREND

  FOR i = 1 to readers DO
    colt $local.j1   until='      END_JOB' sm='?'
      LOGIN USER=?user_string? PASSWORD=?password_string? FN=?family_string?
       IF ?handler? THEN
         WHEN any_fault do
           reqoa ' READ?$strrep(i)? failed  '//$condition_name(osv$status.condition)
           display_value osv$status
           logout
         WHENEND
       IFEND

      attach_file $user.share.1 am=?$parameter(access_modes)? sm=?$parameter(share_modes)? lfn=share
      exet sp=dfp$test_file_reading ..
  p='lfn=share, owr=?$strrep(i)?,tm=?$strrep(tm)?,wm=?$strrep(wm)?,pc=?$strrep(page_count)?'
       IF NOT ?save_output? THEN
         terp output
      IFEND
      LOGOUT
      END_JOB
    submit_job $local.j1 user_job_name=$name('READ'//$strrep(i))
  FOREND

PROCEND dfm$shareit

