diff --git a/TP3/coordinator.cpp b/TP3/coordinator.cpp index d37a7f0..dc4b1fa 100644 --- a/TP3/coordinator.cpp +++ b/TP3/coordinator.cpp @@ -17,8 +17,8 @@ int listener(); class remoteMutex { private: - queue> mutexQ; mutex mtx; + queue> mutexQ; bool acquired = false; map granted_map; void grantNext() @@ -57,8 +57,8 @@ class remoteMutex } void release() { - cout << "RELEASED" << endl; mtx.lock(); + cout << "RELEASED" << endl; if (mutexQ.empty()) { acquired = false; @@ -182,6 +182,7 @@ int listener() } else if (msg == RELEASE) { + cout << process << " "; rmutex.release(); } else diff --git a/TP3/test_0.sh b/TP3/test_0.sh new file mode 100644 index 0000000..0148917 --- /dev/null +++ b/TP3/test_0.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +./cliente 2 10 172.26.86.132 & +./cliente 2 10 172.26.86.132 & + +wait \ No newline at end of file diff --git a/TP3/test_1.sh b/TP3/test_1.sh new file mode 100644 index 0000000..f195236 --- /dev/null +++ b/TP3/test_1.sh @@ -0,0 +1,9 @@ +#!/bin/bash + + +for i in 4 8 16 32; do + for j in $(seq $i); do + ./cliente 2 10 172.26.86.132 & + done + wait +done \ No newline at end of file diff --git a/lib/MyLib.cpp b/lib/MyLib.cpp index ea58d09..52649c8 100644 --- a/lib/MyLib.cpp +++ b/lib/MyLib.cpp @@ -3,7 +3,6 @@ #include #include "MyLib.h" #include -#include using namespace std; @@ -25,6 +24,11 @@ char *encode(int msg, int id) } void decode(char *buffer, int *message, int *id) { - *message = stoi(strtok(buffer, "|")); - *id = stoi(strtok(NULL, "|")); + string delimiter = "|"; + string s(buffer); + size_t pipe1 = s.find(delimiter); + *message = stoi(s.substr(0, pipe1)); + s.erase(0, pipe1 + 1); + size_t pipe2 = s.find(delimiter); + *id = stoi(s.substr(0, pipe2)); } \ No newline at end of file