Skip to content

Added bankersalgorithm.java#3427

Open
Nidakhan786 wants to merge 2 commits intoOpenGenus:masterfrom
Nidakhan786:bankerslgorithm
Open

Added bankersalgorithm.java#3427
Nidakhan786 wants to merge 2 commits intoOpenGenus:masterfrom
Nidakhan786:bankerslgorithm

Conversation

@Nidakhan786
Copy link
Contributor

Fixes issue:
N/A

Changes:
Added bankersalgorithm.java


// Get Allocation input
System.out.println("Enter allocation matrix -->");
for (int i = 0; i < processes; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preincrement.

System.out.println("");
}

//
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment?

printArray(calc_need());
}
static void printArray(int[][] array) {
for (int i = 0; i < array.length; i++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May I recommend the Java for each loop?

// checking if all resources for ith process can be allocated
for (int j = 0; j < resources; j++)
if (available_resources[0][j] < need[i][j])
return false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent

int j = 0;

while (j < processes) { // until all process allocated
boolean allocated = false;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation fix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants