#ifndef DEADLOCKAVOID_HPP #define DEADLOCKAVOID_HPP #include #include enum RequestResult{ WAIT, NOT_SAFE, SAFE }; namespace DeadlockAvoidance { /****************************************************** * check to see if the current status is safe * * @return true if state is safe and false otherwise * * @param Max is n x m matrix of maximum resources * * @param Alloc is n x m matrix of allocated resources* * @param Need is n x m matrix of needed resources * * @param Available is m size avaliable resource vec * *****************************************************/ template > class CONT > bool isSafe(boost::numeric::ublas::matrix, boost::numeric::ublas::matrix, boost::numeric::ublas::matrix); /****************************************************** * check to see if the current request can be made * * @return a container holding request result * * @param Max is n x m matrix of maximum resources * * @param Alloc is n x m matrix of allocated resources* * @param Need is n x m matrix of needed resources * * @param Available is m size avaliable resource vec * * @param Request is n x m matrix of request made * ******************************************************/ template > class CONT > CONT isRequest(boost::numeric::ublas::matrix, boost::numeric::ublas::matrix, boost::numeric::ublas::matrix, boost::numeric::ublas::matrix); /****************************************************** * check to see if the request results in deadlock * * @return a container holding true false value * * @param Alloc is n x m matrix of allocated resources* * @param Available is m size avaliable resource vec * * @param Request is n x m matrix of request made * ******************************************************/ template > class CONT > CONT DeadLockDetect( boost::numeric::ublas::matrix, boost::numeric::ublas::matrix, boost::numeric::ublas::matrix); /******************************************************** * Prints out the content of the given request result * * @param request: is the request result * * SAFE -> "Process is safe" * * UNSAFE -> "Process is unsafe" * * WAIT -> "Process must wait" * *******************************************************/ template < template > class CONT> void print_request(const CONT&); } #endif