aboutsummaryrefslogtreecommitdiff
path: root/src/util/test_scheduler_hogging_priority.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/util/test_scheduler_hogging_priority.c')
-rw-r--r--src/util/test_scheduler_hogging_priority.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/util/test_scheduler_hogging_priority.c b/src/util/test_scheduler_hogging_priority.c
new file mode 100644
index 000000000..217a39ce7
--- /dev/null
+++ b/src/util/test_scheduler_hogging_priority.c
@@ -0,0 +1,55 @@
1#include "gnunet_util_lib.h"
2#include <unistd.h>
3
4static int count = 0;
5static int final_count;
6
7static void end (void *cls)
8{
9 final_count = count;
10 count = 5000;
11 GNUNET_SCHEDULER_shutdown ();
12}
13
14static void self_rescheduling (void *cls)
15{
16 if (count == 0)
17 {
18 GNUNET_SCHEDULER_add_delayed_with_priority (GNUNET_TIME_UNIT_MILLISECONDS,
19 GNUNET_SCHEDULER_PRIORITY_URGENT,
20 &end,
21 NULL);
22 sleep(1);
23 /* end should be added to ready queue on next scheduler pass for certain
24 now */
25 }
26 if (++count < 5000)
27 {
28 GNUNET_SCHEDULER_add_now (&self_rescheduling, NULL);
29 }
30}
31
32
33static void noop (void *cls)
34{
35}
36
37static void indirection (void *cls)
38{
39 GNUNET_SCHEDULER_add_with_reason_and_priority (&self_rescheduling, NULL,
40 GNUNET_SCHEDULER_REASON_STARTUP,
41 GNUNET_SCHEDULER_PRIORITY_HIGH);
42}
43
44static void init (void *cls)
45{
46 GNUNET_SCHEDULER_add_now (&indirection, NULL);
47 GNUNET_SCHEDULER_add_now (&noop, NULL);
48}
49
50
51int main (int argc, char **argv)
52{
53 GNUNET_SCHEDULER_run (&init, NULL);
54 return final_count < 5000 ? 0 : 1;
55}