Scheduler is now selectable in make menuconfig in kernel hacking.
[projects/modsched/linux.git] / kernel / sched / modsched / framework / sys / fw_comm.c
1 /*
2  * fw_comm.c
3  *
4  * Simplistic Pub-Sub-System
5  *
6  *              Author: Anselm Busse, Daniel Roehrig, Christian Rene Sechting
7  */
8
9 #include "fw_comm.h"
10 #include "fw_list.h"
11 #include "fw.h"
12
13 fw_list_head_t topics[FW_LAST-FW_FIRST];
14
15 struct fw_topic_element {
16         fw_list_head_t list;
17         void *callback;
18 };
19
20
21 void fw_subscribe(topic_t topic, void *callback)
22 {
23         struct fw_topic_element *subscriber = fw_malloc(sizeof(struct fw_topic_element));
24         subscriber->callback = callback;
25         fw_list_add_tail(&subscriber->list, &topics[topic]);
26 }
27
28 void fw_notify(topic_t topic, void *data)
29 {
30         struct fw_topic_element *iter;
31
32         fw_list_for_each_entry(iter, &topics[topic], list)
33                 ((void (*)(void *))iter->callback)(data);
34 }
35
36 void fw_init_comm()
37 {
38         int i;
39
40         for(i=FW_FIRST; i<FW_LAST; i++){
41                 FW_LIST_INIT(topics[i]);
42         }
43 }