Przeglądaj źródła

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 14 lat temu
rodzic
commit
421cba5d6b
2 zmienionych plików z 18 dodań i 0 usunięć
  1. 15 0
      timer_proc.c
  2. 3 0
      timer_proc.h

+ 15 - 0
timer_proc.c

@@ -36,12 +36,25 @@
  */
 
 #include "timer_proc.h"
+#include "cfg/cfg_struct.h"
 #include "pt.h"
 #include "mem/shm_mem.h"
 
 #include <unistd.h>
 
 
+/** update internal counters for running new dummy timers
+ *  @param timers - number of dummy timer processes
+ *  @return - 0 on success; -1 on error
+ */
+int register_dummy_timers(int timers)
+{
+	if(register_procs(timers)<0)
+		return -1;
+	cfg_register_child(timers);
+	return 0;
+}
+
 /** forks a separate simple sleep() periodic timer.
   * Forks a very basic periodic timer process, that just sleep()s for 
   * 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,
 	if (pid<0) return -1;
 	if (pid==0){
 		/* child */
+		if (cfg_child_init()) return -1;
 		for(;;){
 			sleep(interval);
+			cfg_update();
 			f(get_ticks(), param); /* ticks in s for compatibility with old
 									  timers */
 		}

+ 3 - 0
timer_proc.h

@@ -36,6 +36,9 @@
 
 #include "local_timer.h"
 
+/** @brief register the number of extra dummy timer processes */
+int register_dummy_timers(int timers);
+
 /** @brief forks a separate simple sleep() periodic timer */
 int fork_dummy_timer(int child_id, char* desc, int make_sock,
 						timer_function* f, void* param, int interval);