Browse code

core: wrapper to pre-register new dummy timers

- register_dummy_timers(no) adds the number of new processes in the
process table and initializes as well the number of new childres
to the cfg framework
- fork_dummy_timer() handles now the updates in cfg framework

Daniel-Constantin Mierla authored on 07/04/2011 18:34:18
Showing 2 changed files
... ...
@@ -36,12 +36,25 @@
36 36
  */
37 37
 
38 38
 #include "timer_proc.h"
39
+#include "cfg/cfg_struct.h"
39 40
 #include "pt.h"
40 41
 #include "mem/shm_mem.h"
41 42
 
42 43
 #include <unistd.h>
43 44
 
44 45
 
46
+/** update internal counters for running new dummy timers
47
+ *  @param timers - number of dummy timer processes
48
+ *  @return - 0 on success; -1 on error
49
+ */
50
+int register_dummy_timers(int timers)
51
+{
52
+	if(register_procs(timers)<0)
53
+		return -1;
54
+	cfg_register_child(timers);
55
+	return 0;
56
+}
57
+
45 58
 /** forks a separate simple sleep() periodic timer.
46 59
   * Forks a very basic periodic timer process, that just sleep()s for 
47 60
   * the specified interval and then calls the timer function.
... ...
@@ -66,8 +79,10 @@ int fork_dummy_timer(int child_id, char* desc, int make_sock,
66 66
 	if (pid<0) return -1;
67 67
 	if (pid==0){
68 68
 		/* child */
69
+		if (cfg_child_init()) return -1;
69 70
 		for(;;){
70 71
 			sleep(interval);
72
+			cfg_update();
71 73
 			f(get_ticks(), param); /* ticks in s for compatibility with old
72 74
 									  timers */
73 75
 		}
... ...
@@ -36,6 +36,9 @@
36 36
 
37 37
 #include "local_timer.h"
38 38
 
39
+/** @brief register the number of extra dummy timer processes */
40
+int register_dummy_timers(int timers);
41
+
39 42
 /** @brief forks a separate simple sleep() periodic timer */
40 43
 int fork_dummy_timer(int child_id, char* desc, int make_sock,
41 44
 						timer_function* f, void* param, int interval);