Sponsored Content
Full Discussion: banker's algorithm.. help
Top Forums UNIX for Dummies Questions & Answers banker's algorithm.. help Post 302629523 by syah on Tuesday 24th of April 2012 11:24:09 PM
Old 04-25-2012
banker's algorithm.. help

i'm doing banker's algorithm..
got some error there but i cant fix it..
please help!!
Code:
#!/bin/bash
echo "enter no.of resources: "
  read n1 
  echo -n "enter the max no .of resources for each type:  " 
  
  for(( i=0; i <$n1; i++ ))
  do 
    read ${t[${b}][${i}]} 
  done
  echo -n "enter no .of process: " ​
  read p 
  echo -n "enter allocation resources: " 
  for((i=0;i<p;i++)) 
  do 
   f[i]=0 
   for((j=0;j<$n1;j++)) 
   do
    read ${a1[${i}][${j}]} 
   done
  done
  for((i=0;i<$p;i++))
  do 
    for((j=0;j<$n1;j++)) 
    do
       if [ ${a1[${i}][${j}]} -le ${t[${b}][${j}]} ] 
        then
        ${t[${b}][${j}]} += ${a1[${i}][${j}]} 
       else 
        echo -n "wrong resources allocation"
       fi
    done
  done
  echo -n "chance of deadlock occurrence after allocation" 
  for((j=0;j<$n1;j++)) 
   do
    echo -n "${a1[${b}][${j}]}" 
   done
  echo -n "enter the max resources for every process"
  for((i=0;i<$p;i++))
  do 
    for((j=0;j<$n1;j++)) 
      do 
      read ${max[${i}][${j}]} 
      ${n[${i}][${j}]}=${max[${i}][${j}]}-${a1[${i}][${j}]} 
      done
   j=0
   echo -n "needed resources for every process to start execution"
  done 
  for((i=0;i<$p;i++))
  do 
   echo -n "${n[${i}][${j}]} , ${n[${i}][${j+1}]} , ${n[${i}][${j+2}]}" 
   echo -n "safe sequence the sequence of process to compute their execution" 
  done
  for ((a=0;a<$p-c;))
  do 
     for ((i=0;i<$p;i++)) 
     do 
      j=0 
      b=0
      if [${f[${i}]} -eq 0] 
       then 
         if [ ${n[${i}][${j}]} -le ${a1[${b}][${j}]} &&
              ${n[${i}][${j+1}]} -le ${a1[${b}][${j+1}]} && 
              ${n[${i}][${j+2}]} -le ${a1[${b}][${j+2}]} ]
            then
              echo -n "process %d execution started and completed,i+1" 
            for((k=0;k<$n-1;k++)) 
            do
              ${a1[${b}][${k}]}+=${a1[${i}][${k}]}
                ${f[${i}]}="1"
                
            done
         else 
         ${f[${i}]}="0"
      fi 
     done
  done

 

6 More Discussions You Might Find Interesting

1. Programming

Feedback algorithm

Hi I search an exemple of scheduling Feedback algorithm, or help about how to create one. Thanks (0 Replies)
Discussion started by: messier79
0 Replies

2. Shell Programming and Scripting

algorithm

PID USERNAME SIZE RSS STATE PRI NICE TIME CPU PROCESS/NLWP 21444 tomusr 213M 61M sleep 29 10 1:20:46 0.1% java/43 21249 root 93M 44M sleep 29 10 1:07:19 0.2% java/56 is there anyway i can use a command to get the total of the SIZE? 306M (Derive from... (5 Replies)
Discussion started by: filthymonk
5 Replies

3. Programming

Please help me to develop algorithm

Hi guys , in my study book from which I re-learn C is task to generate all possible characters combination from numbers entered by the user. I know this algorithm must use combinatorics to calculate all permutations. Problem is how to implement algortihm. // This program reads the four numbers... (0 Replies)
Discussion started by: solaris_user
0 Replies

4. Programming

Looking for Your Help on dijkstra algorithm

Can you help to adjust the void dijkstra(int s) function to find a path from source to every node so that the minimum cost on that path is maximum. Ex: From 1 to 2 we have 1 - 3 - 4 - 2 , costs(2+3+4+5) From 1 to 2 we have 1 - 5 - 6 - 2 , costs(3+3+4+5) I need the algorithm to choose path 1... (4 Replies)
Discussion started by: ali2011
4 Replies

5. Homework & Coursework Questions

Heuristic Algorithm Example

Give a counter example such that the following heuristic algorithm, for the 2-tape problem, doesn't always produce the best solution: Algorithm: Sort {Xi} in descending order. Place files in tapes one at a time. For a file being considered, assign the file to the smaller tape. Thanks in... (1 Reply)
Discussion started by: sureshcisco
1 Replies

6. Homework & Coursework Questions

Banker's algorithm

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: shell scripts to simulate Banker’s algorithm on a collection of processes (process details are entered as inputs... (4 Replies)
Discussion started by: syah
4 Replies
asadmin-list-jms-resources(1AS) 				   User Commands				   asadmin-list-jms-resources(1AS)

NAME
list-jms-resources - gets all the JMS resources SYNOPSIS
list-jms-resources --user admin_user [--password admin_password][--host localhost] [--port 4848] [--secure|-s] [--passwordfile filename] [--terse=false] [--echo=false] [--interactive=true] [--restype resource_type] Gets all the JMS resources. This command can only be run remotely. OPTIONS
--user authorized domain application server administrative username. --password password to administer the domain application server. --host machine name where the domain application server is running. --port port number of the domain application server listening for administration requests. --secure if true, uses SSL/TLS to communicate with the domain application server. --passwordfile file containing the domain application server password. --terse indicates that any output data must be very concise, typically avoiding human-friendly sentences and favoring well- formatted data for consumption by a script. --echo setting to true will echo the command line statement on the standard output. --interactive prompts you for the required options that are not already specified. --restype JMS resource type which can be: javax.jms.Topic, javax.jms.Queue, javax.jms.TopicConnectionFactory, javax.jms.QueueConnectionFactory. Example 1: Using the list-jms-resources command to list all JMS resources asadmin> list-jms-resources jms/Queue jms/Topic jms/QueueConnectionFactory jms/DurableTopicConnectionFactory Command list-jms-resources executed successfully Example 2: Using the list-jms-resources command to list JMS resources of a specified type asadmin> list-jms-resources --restype javax.jms.TopicConnectionFactory jms/DurableTopicConnectionFactory jms/TopicConnectionFactory Command list-jms-resources executed successfully EXIT STATUS
0 command executed successfully 1 error in executing the command asadmin-create-jms-resource(1AS), asadmin-delete-jms-resource(1AS) J2EE 1.4 SDK March 2004 asadmin-list-jms-resources(1AS)
All times are GMT -4. The time now is 03:00 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy