static node_state_t state = PASSIVE_STATE;
static int parent = -1; // -1 indicates null/no parent
static int deficit = 0; // C_i counter (unacknowledged messages)
-static bool is_initiator = false;
+static bool initiator = false;
// --- HELPER FUNCTION ---
// MUST BE DECLARED ABOVE THE OTHER FUNCTIONS!
{
if (state == PASSIVE_STATE && deficit == 0)
{
- if (is_initiator) {
+ if (initiator) {
// Root is passive and deficit is 0 -> Global Termination!
return;
}
{
thread_args_t *args = _args;
int id = args->id;
- is_initiator = args->initiator;
+ initiator = args->initiator;
// (Removed unused 'processes' variable to fix compiler warning)
pthread_mutex_lock(&state_mutex);
// CHECK GLOBAL TERMINATION CONDITION
- if (is_initiator && state == PASSIVE_STATE && deficit == 0)
+ if (initiator && state == PASSIVE_STATE && deficit == 0)
{
trace("%d: [CONTROL] GLOBAL TERMINATION DETECTED!\n", id);
pthread_mutex_unlock(&state_mutex);
void control_basic_start_hook(int id)
{
pthread_mutex_lock(&state_mutex);
- state = is_initiator ? ACTIVE_STATE : PASSIVE_STATE;
+ state = initiator ? ACTIVE_STATE : PASSIVE_STATE;
parent = -1;
deficit = 0;
pthread_mutex_unlock(&state_mutex);