2 * \file ferret/examples/merge_mon/poll.c
3 * \brief polls for outstanding sensors
6 * \author Ronald Aigner <ra3@os.inf.tu-dresden.de>
9 * (c) 2007-2009 Technische Universität Dresden
10 * This file is part of TUD:OS and distributed under the terms of the
11 * GNU General Public License 2.
12 * Please see the COPYING-GPL-2 file for details.
17 #include <l4/sys/cache.h>
18 #include <l4/util/util.h>
20 #include <l4/ferret/monitor.h>
21 #include <l4/ferret/comm.h>
22 #include <l4/ferret/sensors/list_consumer.h>
23 //#include <l4/ferret/sensors/tbuf_consumer.h>
28 static void polling_thread(void* arg)
39 for (i = 0; i < sensor_count; i++)
44 l4_cap_idx_t srv = lookup_sensordir();
47 ret = ferret_att(srv, sensors[i].major, sensors[i].minor,
48 sensors[i].instance, sensors[i].sensor);
53 printf("Still could not attach to %hu:%hu:%hu, retrying!\n",
54 sensors[i].major, sensors[i].minor,
60 // this looks a bit racy ...
61 sensors[i].copied = 0;
62 sensors[i].last_lost = 0;
63 sensors[i].last_ts = 0;
65 type = ((ferret_common_t *)(sensors[i].sensor))->type;
66 if (type != FERRET_LIST && type != FERRET_TBUF)
68 printf("Found wrong sensor type (%d): %hu!\n", i, type);
73 printf("Attached to %hu:%hu:%hu.\n",
74 sensors[i].major, sensors[i].minor,
78 __asm__ __volatile__("": : :"memory"); // barrier
84 void poll_sensors(void)
86 l4thread_create_named(polling_thread, ".poll", 0, L4THREAD_CREATE_ASYNC);