Your question is Deadlock Implementation. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
HPE Ezmeral workloads may have processes holding resource instances while waiting for additional instances. Given a snapshot of resource availability, allocations, and outstanding requests, return every process that can never complete because of a deadlock.
Use the standard deadlock-detection algorithm: assume a process can finish when all of its outstanding requests can be satisfied by the currently available resources. When it finishes, release its allocated resources and continue checking other processes. Processes that remain unfinished are deadlocked.
Implement detect_deadlock(available, allocation, requests).
available is an integer array of length R, where available[j] is the number of currently free instances of resource type j.allocation is an integer matrix with P rows and R columns. allocation[i][j] is held by process i.requests is an integer matrix with the same dimensions. requests[i][j] is the additional number of instances process i needs to finish.[] if no deadlock exists.def detect_deadlock(available, allocation, requests):