]>
vgcfreebox.myrthtech.pt Git - ue-pp-terminationdetectionalgorithm.git/blob - control-skeleton.c
464b8cc0b78de4e732ed745d0174ce1440d84a76
2 Parallel Programming - 2026/2027
4 Skeleton of an implementation of a termination detection algorithm
18 // the tag(s) of the control messages
21 // type for control messages
24 //} control_message_t;
30 Main loop of the termination detection algorithm.
32 When termination is detected, it must end (returning NULL or another
33 appropriate value), which signals the main thread that the basic
34 algorithm has terminated.
36 The arguments of the termination detection algorithm are the ID of
37 the process, the number of PROCESSES running the basic algorithm,
38 and whether the process is an initiator.
40 void *detect_termination(void *_args
)
42 thread_args_t
*args
= _args
;
44 int processes
= args
->processes
;
45 bool initiator
= args
->initiator
;
47 // THE FOLLOWING TWO LINES OF CODE MUST BE REPLACED BY THE CODE OF
48 // THE TERMINATION DETECTION ALGORITHM
50 // let the basic algorithm run for 10 seconds
57 Called at startup of the basic algorithm in process ID.
59 void control_basic_start_hook(int id
)
64 Called when the basic algorithm process ID becomes passive.
66 void control_become_passive_hook(int id
)
71 Called when the basic algorithm process ID becomes active.
73 void control_become_active_hook(int id
)
78 Called when the basic algorithm process ID sends a basic message to
81 void control_basic_send_hook(int id
, int peer
)
86 Called when the basic algorithm process ID receives a basic message
89 void control_basic_receive_hook(int id
, int peer
)