bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Job Scheduling


From: Bruce M Beach
Subject: Job Scheduling
Date: Wed, 14 Aug 2002 17:21:23 +0000 (UTC)

  The following code is really the same as the SIGCHLD test in the
  bash test suite modified to do something interesting. In buildp()
  a list of jobs is converted into an array for the trap to process
  and the trap is set up.  A number of sleeps trigger the subsequent
  events.

  Every time trapp() is called it starts a new job so that
  there are always n job's running concurently where n= number of
  initial sleeps, in the case of the example 4.

  Just out of interest I do this with a system build on a 2 processor
  board and get the following results. (where the "make install" phase
  in both builds is missing) Both builds show no problems in the
  log files.

       n_system.sh build_all       = 02:02:21 <-- serial build
       n_system.sh buildp pall_srt = 01:02:48 <-- parallel build

  What worries me is when I replace the sleeps with
  something else, say

       echo "Starting process One"   &
       echo "Starting process Two"   &
       echo "Starting process Three" &
       echo "Starting process Four"  &

  I get

      ------------------------------ in trap sigchld --
      [1]  26903 Done                    echo "Starting process one"
      [2]  26904 Done                    echo "Starting process two"
      [3]+ 26906 Running                 ${ARRAY_LIST[BUILD_CNT]} >/dev/null &
      ------------------------------ in trap sigchld --
      [1]  26903 Done                    echo "Starting process one"
      [2]  26904 Done                    echo "Starting process two"
      [3]- 26906 Running                 ${ARRAY_LIST[BUILD_CNT]} >/dev/null &
      [4]+ 26907 Running                 ${ARRAY_LIST[BUILD_CNT]} >/dev/null &
      ./n_system.sh: child setpgid (26906 to 26905): Operation not permitted
      in zlib-1.1.4 0

  Is this expected behaviour? (With the sleeps the script shows no
  problems)

  Bruce


#------------------- START OF CODE -------------------------
buildp() { # --------------- START BUILD_PARA
  BUILD_CNT=0                      # convert the list into an array so that
  NO_BUILDS=0                      # the trap can access the builds one at
  for APP in $BUILD_LIST;          # a time. Wish I knew a better way to
  do                               # do this like directly feed the list
       ARRAY_LIST[NO_BUILDS]=$APP  # into the trap and process it with a
       ((NO_BUILDS++))             # regular expression
  done
  set -o monitor                   # enable jobs
  set -b                           # enable immediate reporting of SIGCHLD
  trap trapp SIGCHLD               # set trap indicating process terminate
     sleep 1 &                     # start build 1 in background
     sleep 2 &                     # start build 2 in background
     sleep 3 &                     # start build 3 in background
     sleep 4 &                     # start build 4 in background
  wait                             # for all builds to finish
  trap SIGCHLD                     # restore signal to default
} #------------------------- END BUILD_PARA

trapp() { #----------------- START TRAPP
  echo '------------------------------ in trap sigchld --'
  if (( $NO_BUILDS - $BUILD_CNT ));           # if list is finished don't start
  then                                        # any new jobs
        ${ARRAY_LIST[BUILD_CNT]} >/dev/null & # run the process
        ((BUILD_CNT++))                       # point to next process to run
  fi
  jobs -l                                     # just list jobs for diagnostics
} #------------------------- END TRAPP




brucemartinbeach@21cn.com






reply via email to

[Prev in Thread] Current Thread [Next in Thread]