source: trunk/IPs/systemC/processor/Morpheo/Script/execute_n.sh @ 82

Last change on this file since 82 was 82, checked in by rosiere, 16 years ago
  • support locale (now must "just" translate)
  • update all component with new test format
  • update all component with usage
  • New component : decod queue and prediction_unit
  • Property svn:keywords set to Id
File size: 2.6 KB
Line 
1#!/bin/sh
2#-----------------------------------------------------------
3# $Id: execute_n.sh 82 2008-05-01 16:48:45Z rosiere $
4#-----------------------------------------------------------
5
6#-----[ variable ]------------------------------------------
7declare -a COMMAND;
8declare -i NB_PROCESS;
9declare -i CPT;
10declare    FILE_CMD;
11declare    FILE_CPT;
12declare    FILE_CPU;
13declare    ID="cpu-${HOSTNAME}-$$"
14
15#-----[ usage ]---------------------------------------------
16function usage ()
17{
18    echo "Usage     : $0 file [ nb_process ]";
19    echo "Arguments : ";
20    echo " * file       : list of command";
21    echo " * nb_process : number of process (default (and maximum) is the number of processor)";
22    echo "";
23    echo "Note      : ";
24    echo " * This script, for each command, create a directory : Task_X (X is the number of command), and execute the command in this directory.";
25    echo " * Two file is generate : \"output\" is the output of the execution, and \"command\" is the command lunch.";
26    echo " * A command empty (no command on a line of file) is a synchronisation with all process"
27    echo " * Don't forgot the final end of line (else the last command is not executed";
28    echo "";
29    exit;
30}
31
32#-----[ nb_cpu ]--------------------------------------------
33function nb_cpu ()
34{
35    local FILE_CPUINFO=/proc/cpuinfo;
36    if test ! -f $FILE_CPUINFO; then
37        echo "\"${FILE_CPUINFO}\" don't exist."
38        usage;
39    fi;
40
41    eval "$1=`grep -c \"processor\" ${FILE_CPUINFO}`";
42}
43
44#-----[ test_usage ]----------------------------------------
45function test_usage ()
46{
47    if test $# -ne 1 -a $# -ne 2; then
48        usage;
49    fi;
50
51    if test ! -f $1; then
52        echo "File \"$1\" don't exist";
53        usage;
54    fi;
55
56    if test ! -s $1; then
57        echo "File \"$1\" is empty";
58        usage;
59    fi;
60}
61
62#-----[ main ]----------------------------------------------
63function main ()
64{
65    nb_cpu NB_PROCESS;
66
67    test_usage $*;
68
69    if test $# -eq 2; then
70        if test $2 -lt $NB_PROCESS; then
71            NB_PROCESS=$2;
72        fi;
73    fi;
74
75    FILE_CMD=$1;
76    FILE_CPT="$HOME/control-"`basename $1`;
77    FILE_CPU="$HOME/$ID";
78
79    echo "<$0>"                                         ;
80    echo "  * Initialisation ...."                      ;
81    echo "    - host name                : $HOSTNAME"   ;
82    echo "    - number of process        : $NB_PROCESS" ;
83
84    local -i IT_NB_PROCESS=1;
85    local -i PID=$$;
86
87    echo "$NB_PROCESS" > $FILE_CPU;
88
89    # create the same number of thread that processor
90    while test $IT_NB_PROCESS -le $NB_PROCESS; do
91        execute.sh $FILE_CMD $FILE_CPT $FILE_CPU &
92        IT_NB_PROCESS=$(($IT_NB_PROCESS+1));
93
94        if test "$$" -ne $PID; then
95            break;
96        fi;
97    done
98}
99
100#-----[ Corps ]---------------------------------------------
101main $*;
Note: See TracBrowser for help on using the repository browser.