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