-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
28 lines (21 loc) · 939 Bytes
/
Copy pathmain.cpp
File metadata and controls
28 lines (21 loc) · 939 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Author: Amir Lorvand
// Project: Banker's Algorithm Deadlock Avoidance Simulation
#include <iostream>
#include "Bankers.h"
int main() {
// initialize a vector for available (free) resources
vector<int> available = {3, 3, 2};
// initialize a vector for the maximum resource that a process needs to complete its task
vector<vector<int>> maxR = {{7, 5, 3},
{3, 2, 2},
{9, 0, 2},
{20, 20, 20},
{4, 3, 3}};
// intialize a vector for the number of resources that currently allocated to each process
vector<vector<int>> allocated = {{0, 1, 0},
{2, 0, 0},
{3, 0, 2},
{2, 1, 1},
{0, 0, 2}};
isSafe(available, maxR, allocated);
}