X-Git-Url: https://rtime.felk.cvut.cz/gitweb/frescor/fna.git/blobdiff_plain/35c75b178ad517d60cd69d3d32582f016b82228b..134806f7924a468e3ebef661f39ae7bc50aa4ad3:/src_frescan/frescan_servers_replenishments.c diff --git a/src_frescan/frescan_servers_replenishments.c b/src_frescan/frescan_servers_replenishments.c index 04202a9..b2e75f4 100644 --- a/src_frescan/frescan_servers_replenishments.c +++ b/src_frescan/frescan_servers_replenishments.c @@ -72,13 +72,12 @@ #include // freelist_t #include // list_add_tail -#include #include "frescan_servers_replenishments.h" #include "frescan_config.h" // FRESCAN_MX_REPL_OPS -#include "frescan_debug.h" // ERROR +#include "frescan_debug.h" // FRESCAN_ERROR #include "frescan_data.h" // frescan_repl_op_t -#include "fosa_threads_and_signals.h" // fosa_thread_attr_init... +#include "fosa.h" // fosa_thread_attr_init, smaller_timespec, incr_timespec #if (FRESCAN_MEASURE_REPL_TH || FRESCAN_MEASURE_REPL_PROGRAM) #include @@ -114,7 +113,7 @@ frescan_repl_op_t *frescan_repl_op_alloc() pos = freelist_alloc(&the_repl_op_pool_freelist); if (pos == -1) { - ERROR("could not allocate repl op\n"); + FRESCAN_ERROR("could not allocate repl op\n"); return NULL; } the_repl_op_pool[pos].pool_pos = pos; // to know how to free it @@ -137,7 +136,7 @@ static void *frescan_repl_thread(void *arg) siginfo_t siginfo; frescan_ss_t id; frescan_network_t net; - frescan_server_data_t *server; + frescan_ss_data_t *server; struct itimerspec timerdata; net = (frescan_network_t)(uint32_t)arg; @@ -165,12 +164,12 @@ static void *frescan_repl_thread(void *arg) siginfo.si_value.sival_int); // the server id id = siginfo.si_value.sival_int; - server = &the_servers_pool[net][id]; + server = &frescan_data[net].ss_data[id]; DEBUG(FRESCAN_REPLENSH_ENABLE_DEBUG, "id:%u current_prio:%u\n", id, server->current_priority); - server->current_priority = server->params.prio; + server->current_priority = server->committed_params.prio; if (!list_empty(&server->packet_list.fifo_list)) { clock_gettime (CLOCK_MONOTONIC, &server->act_time); @@ -204,7 +203,7 @@ int frescan_replenishments_init(frescan_network_t net) ret = frescan_repl_op_init(); if (ret != 0) { - ERROR("could not init repl_op pool\n"); + FRESCAN_ERROR("could not init repl_op pool\n"); return ret; } @@ -212,7 +211,7 @@ int frescan_replenishments_init(frescan_network_t net) ret = fosa_set_accepted_signals(signal_set, 1); if (ret != 0) { - ERROR("could not set the repl signal\n"); + FRESCAN_ERROR("could not set the repl signal\n"); return ret; } @@ -229,29 +228,29 @@ int frescan_replenishments_init(frescan_network_t net) ret = fosa_thread_attr_init(&attr); if (ret != 0) { - ERROR("could not init thread attributes\n"); + FRESCAN_ERROR("could not init thread attributes\n"); return ret; } ret = fosa_thread_attr_set_prio(&attr, FRESCAN_REPL_THREAD_PRIO); if (ret != 0) { - ERROR("could not set repl thread prio %d\n", + FRESCAN_ERROR("could not set repl thread prio %d\n", FRESCAN_REPL_THREAD_PRIO); return ret; } - ret = fosa_thread_create(&the_networks[net].repl_thread_id, + ret = fosa_thread_create(&frescan_data[net].repl_thread_id, &attr, frescan_repl_thread, (void *)(uint32_t)net); if (ret != 0) { - ERROR("could not create the replenishment thread\n"); + FRESCAN_ERROR("could not create the replenishment thread\n"); return ret; } ret = fosa_thread_attr_destroy(&attr); if (ret != 0) { - ERROR("could not destroy thread attributes\n"); + FRESCAN_ERROR("could not destroy thread attributes\n"); return ret; } @@ -266,13 +265,13 @@ int frescan_replenishments_init(frescan_network_t net) */ int frescan_replenishment_program(frescan_network_t net, - frescan_ss_t ss, + frescan_ss_t id, const struct timespec *timestamp) { int ret; frescan_repl_op_t *repl = NULL; struct itimerspec timerdata; - frescan_server_data_t *server; + frescan_ss_data_t *server; struct list_head *pos; struct timespec now; @@ -281,7 +280,7 @@ int frescan_replenishment_program(frescan_network_t net, assert(ret == 0); #endif - server = &the_servers_pool[net][ss]; + server = &frescan_data[net].ss_data[id]; // extract the head list_for_each(pos, &server->replenishments.repl_list) { @@ -292,7 +291,7 @@ int frescan_replenishment_program(frescan_network_t net, // move to tail with new repl value repl->when = *timestamp; - incr_timespec (&repl->when, &server->params.values.period); + incr_timespec(repl->when, server->committed_params.period); repl->amount = 1; list_add_tail(&repl->repl_list, @@ -306,7 +305,7 @@ int frescan_replenishment_program(frescan_network_t net, clock_gettime (CLOCK_MONOTONIC, &now); - if (smaller_timespec(&now, &repl->when)) { + if (smaller_timespec(now, repl->when)) { server->current_priority = FRESCAN_BACKGROUND_PRIO; timerdata.it_interval.tv_sec = 0; @@ -320,7 +319,7 @@ int frescan_replenishment_program(frescan_network_t net, ret = timer_settime(server->repl_timer, TIMER_ABSTIME, &timerdata, NULL); if (ret != 0) { - ERROR("could not set the replenishment timer\n"); + FRESCAN_ERROR("could not set the replenishment timer\n"); return ret; } }