]>
vgcfreebox.myrthtech.pt Git - ue-pp-terminationdetectionalgorithm.git/blob - util.c
65e145edeeb99038286a2309462f657f07f6d0cd
2 Parallel Programming - 2026/2027
13 // controls the output of debugging messages, set to 1 to have no
18 // returns a random integer in [A,B]
19 int rand_ab(int a
, int b
)
21 return a
+ rand() % (b
- a
+ 1);
24 // sleep between MIN and MAX ms
25 void rand_sleep(int min
, int max
)
27 int ms
= rand_ab(min
, max
);
28 struct timespec ts
= { ms
/ 1000, (ms
% 1000) * 1000 };
33 // output a debugging message to stderr
34 void trace(char *format
, ...)
41 va_start (args
, format
);
42 vfprintf(stderr
, format
, args
);
46 // unconditionally output a message to stderr
47 void warn(char *format
, ...)
51 va_start (args
, format
);
52 vfprintf(stderr
, format
, args
);