]> rtime.felk.cvut.cz Git - frescor/fna.git/blobdiff - src_frescan/frescan_servers_replenishments.c_posix
licenses
[frescor/fna.git] / src_frescan / frescan_servers_replenishments.c_posix
index 32d54a59c9a9a5370d2a74f57db46d2c8f005fc5..7923c357586069d0a7eabe00d4946a21b65d89f2 100644 (file)
  *
  * @license
  *
- * See MaRTE OS license
+ * -----------------------------------------------------------------------
+ *  Copyright (C) 2006 - 2008 FRESCOR consortium partners:
+ *
+ *    Universidad de Cantabria,              SPAIN
+ *    University of York,                    UK
+ *    Scuola Superiore Sant'Anna,            ITALY
+ *    Kaiserslautern University,             GERMANY
+ *    Univ. Politécnica  Valencia,           SPAIN
+ *    Czech Technical University in Prague,  CZECH REPUBLIC
+ *    ENEA                                   SWEDEN
+ *    Thales Communication S.A.              FRANCE
+ *    Visual Tools S.A.                      SPAIN
+ *    Rapita Systems Ltd                     UK
+ *    Evidence                               ITALY
+ *
+ *    See http://www.frescor.org for a link to partners' websites
+ *
+ *           FRESCOR project (FP6/2005/IST/5-034026) is funded
+ *        in part by the European Union Sixth Framework Programme
+ *        The European Union is not liable of any use that may be
+ *        made of this code.
+ *
+ *  This file is part of FRESCAN
+ *
+ *  FRESCAN is free software; you can  redistribute it and/or  modify
+ *  it under the terms of  the GNU General Public License as published by
+ *  the Free Software Foundation;  either  version 2, or (at  your option)
+ *  any later version.
+ *
+ *  FRESCAN  is distributed  in  the hope  that  it  will  be useful,  but
+ *  WITHOUT  ANY  WARRANTY;     without  even the   implied   warranty  of
+ *  MERCHANTABILITY  or  FITNESS FOR  A  PARTICULAR PURPOSE. See  the  GNU
+ *  General Public License for more details.
+ *
+ *  You should have  received a  copy of  the  GNU  General Public License
+ *  distributed  with  FRESCAN;  see file COPYING.   If not,  write to the
+ *  Free Software  Foundation,  59 Temple Place  -  Suite 330,  Boston, MA
+ *  02111-1307, USA.
+ *
+ * As a special exception, including FRESCAN header files in a file,
+ * instantiating FRESCAN generics or templates, or linking other files
+ * with FRESCAN objects to produce an executable application, does not
+ * by itself cause the resulting executable application to be covered
+ * by the GNU General Public License. This exception does not
+ * however invalidate any other reasons why the executable file might be
+ * covered by the GNU Public License.
+ * -----------------------------------------------------------------------
  *
  */
 
 #include <time.h>            // clock_gettime
+#include <assert.h>          // assert
 
 #include <misc/freelist.h>   // freelist_t
 #include <misc/linux_list.h> // list_add_tail
 #include "frescan_data.h"    // frescan_repl_op_t
 #include "fosa_threads_and_signals.h" // fosa_thread_attr_init...
 
+#if (FRESCAN_MEASURE_REPL_TH || FRESCAN_MEASURE_REPL_PROGRAM)
+#include <misc/time_measurement_posix.h>
+#include <misc/logger.h>
+static time_measure_id_t measure_id;
+#endif
+
 /**
  * the_repl_op_pool - pool of replenishment operations
  *
@@ -97,6 +150,10 @@ static void *frescan_repl_thread(void *arg)
         sigaddset(&set, FRESCAN_REPL_SIGNAL_NUM);
 
         while (1) {
+#if FRESCAN_MEASURE_REPL_TH
+                ret = time_measure_posix_begin(measure_id);
+                assert(ret == 0);
+#endif
                 ret = sigwaitinfo(&set, &siginfo);
                 if (ret == -1) {
                         ERROR("sigwaitinfo failed\n");
@@ -171,6 +228,12 @@ static void *frescan_repl_thread(void *arg)
                         ERROR("could not set replenishment timer\n");
                         return NULL;
                 }
+#if FRESCAN_MEASURE_REPL_TH
+                ret = time_measure_posix_end(measure_id, "thread");
+                assert(ret == 0);
+
+                while (logger_manual_call() > 0);
+#endif
         }
 
         return NULL;
@@ -207,6 +270,15 @@ int frescan_replenishments_init(frescan_network_t net)
         }
 
         // create the replenishment thread
+#if (FRESCAN_MEASURE_REPL_TH || FRESCAN_MEASURE_REPL_PROGRAM)
+        ret = logger_init(LOG_ETHERNET);
+        assert(ret == 0);
+
+        ret = time_measure_posix_create("repl",
+                                        CLOCK_THREAD_CPUTIME_ID,
+                                        &measure_id);
+        assert(ret == 0);
+#endif
 
         ret = fosa_thread_attr_init(&attr);
         if (ret != 0) {
@@ -256,6 +328,11 @@ int frescan_replenishment_program(frescan_network_t net,
         struct itimerspec timerdata;
         frescan_server_data_t *server;
 
+#if FRESCAN_MEASURE_REPL_PROGRAM
+        ret = time_measure_posix_begin(measure_id);
+        assert(ret == 0);
+#endif
+
         server = &the_servers_pool[net][ss];
 
         repl = frescan_repl_op_alloc();
@@ -291,5 +368,12 @@ int frescan_replenishment_program(frescan_network_t net,
                 }
         }
 
+#if FRESCAN_MEASURE_REPL_PROGRAM
+                ret = time_measure_posix_end(measure_id, "program");
+                assert(ret == 0);
+
+                while (logger_manual_call() > 0);
+#endif
+
         return 0;
 }