Keep track of when the last restart and work updates were triggered and provide helper functions for knowing the time since then.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
diff --git a/cgminer.c b/cgminer.c
index 2370b6a..9be9e86 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -280,6 +280,7 @@ pthread_cond_t gws_cond;
double total_rolling;
double total_mhashes_done;
static struct timeval total_tv_start, total_tv_end;
+static struct timeval restart_tv_start, update_tv_start;
cglock_t control_lock;
pthread_mutex_t stats_lock;
@@ -2336,6 +2337,22 @@ double cgpu_runtime(struct cgpu_info *cgpu)
return dev_runtime;
}
+double tsince_restart(void)
+{
+ struct timeval now;
+
+ cgtime(&now);
+ return tdiff(&now, &restart_tv_start);
+}
+
+double tsince_update(void)
+{
+ struct timeval now;
+
+ cgtime(&now);
+ return tdiff(&now, &update_tv_start);
+}
+
static void get_statline(char *buf, size_t bufsiz, struct cgpu_info *cgpu)
{
char displayed_hashes[16], displayed_rolling[16];
@@ -4305,6 +4322,7 @@ static void restart_threads(void)
{
pthread_t rthread;
+ cgtime(&restart_tv_start);
if (unlikely(pthread_create(&rthread, NULL, restart_thread, NULL)))
quit(1, "Failed to create restart thread");
}
@@ -4315,6 +4333,7 @@ static void signal_work_update(void)
applog(LOG_INFO, "Work update message received");
+ cgtime(&update_tv_start);
rd_lock(&mining_thr_lock);
for (i = 0; i < mining_threads; i++)
mining_thr[i]->work_update = true;
diff --git a/miner.h b/miner.h
index f557b0d..353b51a 100644
--- a/miner.h
+++ b/miner.h
@@ -679,6 +679,8 @@ endian_flip128(void __maybe_unused *dest_p, const void __maybe_unused *src_p)
#endif
extern double cgpu_runtime(struct cgpu_info *cgpu);
+extern double tsince_restart(void);
+extern double tsince_update(void);
extern void __quit(int status, bool clean);
extern void _quit(int status);