#!/bin/csh -f
#
# fix max-proc-threads in each listed dir 
#
# Part of
#              The STARFISH Parallel file-system simulator
#        (Simulation Tool for Advanced Research in File Systems)
# 
#                               David Kotz
#                           Dartmouth College
#                              Version 3.0
#                              January 1996
#                          dfk@cs.dartmouth.edu


foreach dirname ($*)

    pushd $dirname

    set Ndisk=`grep NO_OF_DISKS disk.param | colex 3`
    echo NO_OF_DISKS is $Ndisk

    set maxout=`grep MAX_OUTSTANDING iopfs.param | colex 3`
    echo MAX_OUTSTANDING is $maxout

    set Nproc=`grep NO_OF_PROCESSORS conf.param | colex 3`
    echo NO_OF_PROCESSORS is $Nproc

    set maxprocthreads=`expr 2 + \( $Nproc - 2 \) \* $Ndisk \* \( $maxout + 1 \)`

    echo MAX_PROC_THREADS should be $maxprocthreads

    setparam MAX_PROC_THREADS $maxprocthreads conf.param

    set maxthreads=`expr \( $Nproc - 2 \) + \( \( $Nproc - 2 \) \* \( $maxout + 1 \) + 1 \) \* $Ndisk`

    echo MAX_THREADS should be $maxthreads

    setparam MAX_THREADS $maxthreads conf.param

    set maxstkblks=`expr 3 \* $maxthreads`

    echo MAX_STKBLKS should be $maxstkblks

    setparam MAX_STKBLKS $maxstkblks sim.param

    popd
end
