Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- int get_resource(int process, int need) {
- // suppose there are X processors and N is the maximum needed
- // resources of each processors, then to get the minimum resources,
- // allocate (N - 1) resources on each (X - 1) processors, therefore, the
- // X-th processor will have no resources
- // allocate 1 resource that will be used to complete the resources
- // required by every processor, and once the (X - 1)-th processor is
- // done processing, then the maximum value will be allocated for the X-th processor
- int mn = 0;
- mn = process * (need - 1) + 1;
- return mn;
- }
- int main() {
- int process = 3;
- int need = 4;
- cout << "R >= " << get_resource(process, need) << "\n";
- return 0;
- }
Add Comment
Please, Sign In to add comment