Skip to content

Commit

Permalink
chore: Update README.md and file names, add Pinterest link and update…
Browse files Browse the repository at this point in the history
… repository description
  • Loading branch information
Pulkit1822 committed Jul 19, 2024
1 parent b81d888 commit 4f684e5
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 28 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# Operating System Algorithms Repository
![OS](https://github.com/Pulkit1822/Personal-Portfolio/blob/main/public/projects/OS.jpg)

Welcome to the OS Algorithms Repository! This repository contains implementations of various OS algorithms in C++. Whether you're a student studying OS or a developer looking to understand these algorithms better, this repository aims to provide clear and concise implementations along with explanations to aid your learning.

Expand Down Expand Up @@ -42,7 +43,7 @@ Contributions to this repository are welcome and encouraged. If you would like t
If you have any feedback, suggestions, or questions regarding this repository, please feel free to open an issue or contact me below on any of the platforms you prefer 😊
<br/>
<p align="center">
<a href="https://pulkitmathur.me/"><img src="https://github.com/Pulkit1822/Pulkit1822/blob/main/animated-icons/pic.jpeg" alt="portfolio" width="32"></a>&nbsp;&nbsp;&nbsp;
<a href="https://pulkitmathur.tech/"><img src="https://github.com/Pulkit1822/Pulkit1822/blob/main/animated-icons/pic.jpeg" alt="portfolio" width="32"></a>&nbsp;&nbsp;&nbsp;
<a href="https://www.linkedin.com/in/pulkitkmathur/"><img src="https://github.com/TheDudeThatCode/TheDudeThatCode/blob/master/Assets/Linkedin.svg" alt="Linkedin Logo" width="32"></a>&nbsp;&nbsp;&nbsp;
<a href="mailto:[email protected]"><img src="https://github.com/TheDudeThatCode/TheDudeThatCode/blob/master/Assets/Gmail.svg" alt="Gmail logo" height="32"></a>&nbsp;&nbsp;&nbsp;
<a href="https://www.instagram.com/pulkitkumarmathur/"><img src="https://github.com/TheDudeThatCode/TheDudeThatCode/blob/master/Assets/Instagram.svg" alt="Instagram Logo" width="32"></a>&nbsp;&nbsp;&nbsp;
Expand Down
Binary file modified Resource Allocation Graph/rag
Binary file not shown.
51 changes: 24 additions & 27 deletions Resource Allocation Graph/rag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,47 +3,44 @@

using namespace std;

int getCountOfResourceCollisions(int numberOfProcesses, vector<int> processes,
int numberOfRows, int numberOfColumns, vector<vector<int>> resources, int resourceToCheck) {
int countOfCollisions = 0;
for (int i = 0; i < numberOfRows; ++i) {
for (int j = 0; j < numberOfColumns; ++j) {
if (resources[i][j] == resourceToCheck) {
++countOfCollisions;
int getCountOfResourceCollisions(int n, vector<int> p, int r, int c, vector<vector<int>> res, int rt) {
int count = 0;
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
if (res[i][j] == rt) {
++count;
}
}
}
return countOfCollisions;
return count;
}

int main() {
int numberOfProcesses, numberOfRows, numberOfColumns, resourceToCheck;
cout << "I have implemented a matrix for resource allocation" << endl;
cout << "Enter the number of processes: " ;
cin >> numberOfProcesses;
vector<int> processes(numberOfProcesses);
cout << "Enter Process Numbers (0-" << numberOfProcesses-1 << " with spaces): " ;
for (int i = 0; i < numberOfProcesses; ++i) {
cin >> processes[i];
int n, r, c, rt;
cout << "Enter the number of processes: ";
cin >> n;
vector<int> p(n);
cout << "Enter Process Numbers (0-" << n-1 << " with spaces): ";
for (int i = 0; i < n; ++i) {
cin >> p[i];
}
cout << "Enter number of rows for resource array: ";
cin >> numberOfRows;
cin >> r;
cout << "Enter number of columns for resource array: ";
cin >> numberOfColumns;
vector<vector<int>> resources(numberOfRows, vector<int>(numberOfColumns));
cin >> c;
vector<vector<int>> res(r, vector<int>(c));
cout << "Enter resources (with spaces): " << endl;
for (int i = 0; i < numberOfRows; ++i) {
for (int j = 0; j < numberOfColumns; ++j) {
cin >> resources[i][j];
for (int i = 0; i < r; ++i) {
for (int j = 0; j < c; ++j) {
cin >> res[i][j];
}
}

cout << "Enter a resource to check if collision happens" << endl;
cin >> resourceToCheck;
cout << "Enter a resource to check if collision happens: ";
cin >> rt;

int countOfCollisions = getCountOfResourceCollisions(numberOfProcesses, processes,
numberOfRows, numberOfColumns, resources, resourceToCheck);
int count = getCountOfResourceCollisions(n, p, r, c, res, rt);

cout << "Counts of deadlock = " << countOfCollisions << endl;
cout << "Counts of deadlock = " << count << endl;
return 0;
}
4 changes: 4 additions & 0 deletions github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# These are supported funding model platforms

github: Pulkit1822
buy_me_a_coffee: pulkitkumarmathur
Binary file modified round_robin_scheduler/round_robin_scheduler
Binary file not shown.

0 comments on commit 4f684e5

Please sign in to comment.