Browse Source

Show "WAIT" (LIFE_WAIT status) if a cgpu is idle waiting for work (pool slow/dead)

Luke Dashjr 13 years ago
parent
commit
d8582964a0
3 changed files with 29 additions and 5 deletions
  1. 3 0
      api.c
  2. 24 4
      cgminer.c
  3. 2 1
      miner.h

+ 3 - 0
api.c

@@ -171,6 +171,7 @@ static const char *DEAD = "Dead";
 static const char *SICK = "Sick";
 static const char *NOSTART = "NoStart";
 static const char *INIT = "Initialising";
+static const char *WAIT = "Waiting";
 static const char *DISABLED = "Disabled";
 static const char *ALIVE = "Alive";
 static const char *REJECTING = "Rejecting";
@@ -1246,6 +1247,8 @@ status2str(enum alive status)
 			return NOSTART;
 		case LIFE_INIT:
 			return INIT;
+		case LIFE_WAIT:
+			return WAIT;
 		default:
 			return UNKNOWN;
 	}

+ 24 - 4
cgminer.c

@@ -1447,6 +1447,8 @@ static void curses_print_devstatus(int thr_id)
 		wprintw(statuswin, "DEAD ");
 	else if (cgpu->status == LIFE_SICK)
 		wprintw(statuswin, "SICK ");
+	else if (cgpu->status == LIFE_WAIT)
+		wprintw(statuswin, "WAIT ");
 	else if (cgpu->deven == DEV_DISABLED)
 		wprintw(statuswin, "OFF  ");
 	else if (cgpu->deven == DEV_RECOVER)
@@ -3362,13 +3364,13 @@ void thread_reportin(struct thr_info *thr)
 {
 	gettimeofday(&thr->last, NULL);
 	thr->cgpu->status = LIFE_WELL;
-	thr->getwork = false;
+	thr->getwork = 0;
 	thr->cgpu->device_last_well = time(NULL);
 }
 
 static inline void thread_reportout(struct thr_info *thr)
 {
-	thr->getwork = true;
+	thr->getwork = time(NULL);
 }
 
 static void hashmeter(int thr_id, struct timeval *diff,
@@ -4583,10 +4585,28 @@ static void *watchdog_thread(void __maybe_unused *userdata)
 			}
 #endif
 			
-			/* Thread is waiting on getwork or disabled */
-			if (thr->getwork || *denable == DEV_DISABLED)
+			/* Thread is disabled */
+			if (*denable == DEV_DISABLED)
 				continue;
 
+			if (thr->getwork) {
+				if (cgpu->status == LIFE_WELL && thr->getwork < now.tv_sec - opt_log_interval) {
+					int thrid;
+					bool cgpu_idle = true;
+					thr->rolling = 0;
+					for (thrid = 0; thrid < cgpu->threads; ++thrid)
+						if (!cgpu->thr[thrid]->getwork)
+							cgpu_idle = false;
+					if (cgpu_idle) {
+						cgpu->rolling = 0;
+						cgpu->status = LIFE_WAIT;
+					}
+				}
+				continue;
+			}
+			else if (cgpu->status == LIFE_WAIT)
+				cgpu->status = LIFE_WELL;
+
 			if (cgpu->rolling < WATCHDOG_LOW_HASH)
 				cgpu->low_count++;
 			else

+ 2 - 1
miner.h

@@ -165,6 +165,7 @@ enum alive {
 	LIFE_DEAD,
 	LIFE_NOSTART,
 	LIFE_INIT,
+	LIFE_WAIT,
 };
 
 
@@ -423,7 +424,7 @@ struct thr_info {
 	struct timeval sick;
 
 	bool	pause;
-	bool	getwork;
+	time_t	getwork;
 	double	rolling;
 
 	bool	work_restart;