GNUnet  0.19.3
speedup.c File Reference

functions to speedup peer execution by manipulation system time More...

#include "platform.h"
#include "gnunet_util_lib.h"
#include "speedup.h"
Include dependency graph for speedup.c:

Go to the source code of this file.

Macros

#define LOG(kind, ...)   GNUNET_log_from (kind, "util-speedup", __VA_ARGS__)
 

Functions

static void do_speedup (void *cls)
 
int GNUNET_SPEEDUP_start_ (const struct GNUNET_CONFIGURATION_Handle *cfg)
 Start task that may speed up our system clock artificially. More...
 
void GNUNET_SPEEDUP_stop_ ()
 Stop tasks that modify clock behavior. More...
 

Variables

static struct GNUNET_TIME_Relative interval
 
static struct GNUNET_TIME_Relative delta
 
static struct GNUNET_SCHEDULER_Taskspeedup_task
 

Detailed Description

functions to speedup peer execution by manipulation system time

Interface for speedup routinues.

Author
Matthias Wachs
Sree Harsha Totakura sreeh.nosp@m.arsh.nosp@m.a@tot.nosp@m.akur.nosp@m.a.in

Definition in file speedup.c.

Macro Definition Documentation

◆ LOG

#define LOG (   kind,
  ... 
)    GNUNET_log_from (kind, "util-speedup", __VA_ARGS__)

Definition at line 31 of file speedup.c.

Function Documentation

◆ do_speedup()

static void do_speedup ( void *  cls)
static

Definition at line 42 of file speedup.c.

43 {
44  static long long current_offset;
45 
46  (void) cls;
47  speedup_task = NULL;
48  current_offset += delta.rel_value_us;
49  GNUNET_TIME_set_offset (current_offset);
51  "Speeding up execution time by %s\n",
54  &do_speedup,
55  NULL);
56 }
@ GNUNET_NO
@ GNUNET_ERROR_TYPE_DEBUG
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_delayed(struct GNUNET_TIME_Relative delay, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run with a specified delay.
Definition: scheduler.c:1241
void GNUNET_TIME_set_offset(long long offset)
Set the timestamp offset for this instance.
Definition: time.c:49
const char * GNUNET_STRINGS_relative_time_to_string(struct GNUNET_TIME_Relative delta, int do_round)
Give relative time in human-readable fancy format.
Definition: strings.c:569
static void do_speedup(void *cls)
Definition: speedup.c:42
static struct GNUNET_TIME_Relative interval
Definition: speedup.c:34
static struct GNUNET_SCHEDULER_Task * speedup_task
Definition: speedup.c:38
#define LOG(kind,...)
Definition: speedup.c:31
static struct GNUNET_TIME_Relative delta
Definition: speedup.c:36
uint64_t rel_value_us
The actual value.

References delta, GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_SCHEDULER_add_delayed(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_TIME_set_offset(), interval, LOG, GNUNET_TIME_Relative::rel_value_us, and speedup_task.

Referenced by GNUNET_SPEEDUP_start_().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SPEEDUP_start_()

int GNUNET_SPEEDUP_start_ ( const struct GNUNET_CONFIGURATION_Handle cfg)

Start task that may speed up our system clock artificially.

Parameters
cfgconfiguration to use
Returns
GNUNET_OK on success, GNUNET_SYSERR if the speedup was not configured

Definition at line 60 of file speedup.c.

61 {
62  GNUNET_assert (NULL == speedup_task);
63  if (GNUNET_OK !=
65  "testing",
66  "SPEEDUP_INTERVAL",
67  &interval))
68  return GNUNET_SYSERR;
69  if (GNUNET_OK !=
71  "testing",
72  "SPEEDUP_DELTA",
73  &delta))
74  return GNUNET_SYSERR;
75 
76  if ((0 == interval.rel_value_us) ||
77  (0 == delta.rel_value_us))
78  {
80  "Speed up disabled\n");
81  return GNUNET_OK;
82  }
84  "Speed up execution by %s\n",
87  "Speed up executed every %s\n",
90  &do_speedup,
91  NULL);
92  return GNUNET_OK;
93 }
static const struct GNUNET_CONFIGURATION_Handle * cfg
Configuration we are using.
Definition: gnunet-abd.c:36
enum GNUNET_GenericReturnValue GNUNET_CONFIGURATION_get_value_time(const struct GNUNET_CONFIGURATION_Handle *cfg, const char *section, const char *option, struct GNUNET_TIME_Relative *time)
Get a configuration value that should be a relative time.
@ GNUNET_OK
@ GNUNET_SYSERR
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
struct GNUNET_SCHEDULER_Task * GNUNET_SCHEDULER_add_now_with_lifeness(int lifeness, GNUNET_SCHEDULER_TaskCallback task, void *task_cls)
Schedule a new task to be run as soon as possible with the (transitive) ignore-shutdown flag either e...
Definition: scheduler.c:1336

References cfg, delta, do_speedup(), GNUNET_assert, GNUNET_CONFIGURATION_get_value_time(), GNUNET_ERROR_TYPE_DEBUG, GNUNET_NO, GNUNET_OK, GNUNET_SCHEDULER_add_now_with_lifeness(), GNUNET_STRINGS_relative_time_to_string(), GNUNET_SYSERR, interval, LOG, GNUNET_TIME_Relative::rel_value_us, and speedup_task.

Referenced by program_main().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GNUNET_SPEEDUP_stop_()

void GNUNET_SPEEDUP_stop_ ( void  )

Stop tasks that modify clock behavior.

Definition at line 100 of file speedup.c.

101 {
102  if (NULL != speedup_task)
103  {
105  speedup_task = NULL;
106  }
107  if ((0 != interval.rel_value_us) &&
108  (0 != delta.rel_value_us))
110  "Stopped execution speed up\n");
111 }
void * GNUNET_SCHEDULER_cancel(struct GNUNET_SCHEDULER_Task *task)
Cancel the task with the specified identifier.
Definition: scheduler.c:944

References delta, GNUNET_ERROR_TYPE_DEBUG, GNUNET_SCHEDULER_cancel(), interval, LOG, GNUNET_TIME_Relative::rel_value_us, and speedup_task.

Referenced by GNUNET_SERVICE_run_(), and shutdown_task().

Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ interval

◆ delta

◆ speedup_task

struct GNUNET_SCHEDULER_Task* speedup_task
static

Definition at line 38 of file speedup.c.

Referenced by do_speedup(), GNUNET_SPEEDUP_start_(), and GNUNET_SPEEDUP_stop_().