aboutsummaryrefslogtreecommitdiff
path: root/cpu-miner.c
diff options
context:
space:
mode:
authorJeff Garzik <jeff@garzik.org>2011-03-17 22:02:28 -0400
committerJeff Garzik <jgarzik@pobox.com>2011-03-17 22:02:28 -0400
commit2d49a9a5d767b85981ce73f1832e0eae06d0d52f (patch)
tree2281b3960552a6fcb14a62f60bbe09b0fafa5227 /cpu-miner.c
parent4be41af2be1b2442161a98b9d7fbf2a61cc854f9 (diff)
Introduce ability to interrupt hash scanners in the middle of scanning.
Diffstat (limited to 'cpu-miner.c')
-rw-r--r--cpu-miner.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/cpu-miner.c b/cpu-miner.c
index 652c35b..7cd6e74 100644
--- a/cpu-miner.c
+++ b/cpu-miner.c
@@ -90,6 +90,7 @@ static char *rpc_url;
static char *userpass;
static struct thr_info *thr_info;
static int work_thr_id;
+struct work_restart *work_restart = NULL;
struct option_help {
@@ -514,7 +515,7 @@ static void *miner_thread(void *userdata)
/* scan nonces for a proof-of-work hash */
switch (opt_algo) {
case ALGO_C:
- rc = scanhash_c(work.midstate, work.data + 64,
+ rc = scanhash_c(thr_id, work.midstate, work.data + 64,
work.hash1, work.hash, work.target,
max_nonce, &hashes_done);
break;
@@ -522,7 +523,7 @@ static void *miner_thread(void *userdata)
#ifdef WANT_X8664_SSE2
case ALGO_SSE2_64: {
unsigned int rc5 =
- scanhash_sse2_64(work.midstate, work.data + 64,
+ scanhash_sse2_64(thr_id, work.midstate, work.data + 64,
work.hash1, work.hash,
work.target,
max_nonce, &hashes_done);
@@ -534,7 +535,7 @@ static void *miner_thread(void *userdata)
#ifdef WANT_SSE2_4WAY
case ALGO_4WAY: {
unsigned int rc4 =
- ScanHash_4WaySSE2(work.midstate, work.data + 64,
+ ScanHash_4WaySSE2(thr_id, work.midstate, work.data + 64,
work.hash1, work.hash,
work.target,
max_nonce, &hashes_done);
@@ -545,19 +546,19 @@ static void *miner_thread(void *userdata)
#ifdef WANT_VIA_PADLOCK
case ALGO_VIA:
- rc = scanhash_via(work.data, work.target,
+ rc = scanhash_via(thr_id, work.data, work.target,
max_nonce, &hashes_done);
break;
#endif
case ALGO_CRYPTOPP:
- rc = scanhash_cryptopp(work.midstate, work.data + 64,
+ rc = scanhash_cryptopp(thr_id, work.midstate, work.data + 64,
work.hash1, work.hash, work.target,
max_nonce, &hashes_done);
break;
#ifdef WANT_CRYPTOPP_ASM32
case ALGO_CRYPTOPP_ASM32:
- rc = scanhash_asm32(work.midstate, work.data + 64,
+ rc = scanhash_asm32(thr_id, work.midstate, work.data + 64,
work.hash1, work.hash, work.target,
max_nonce, &hashes_done);
break;
@@ -595,6 +596,14 @@ out:
return NULL;
}
+void restart_threads(void)
+{
+ int i;
+
+ for (i = 0; i < opt_n_threads; i++)
+ work_restart[i].restart = 1;
+}
+
static void show_usage(void)
{
int i;
@@ -761,6 +770,10 @@ int main (int argc, char *argv[])
if (!thr_info)
return 1;
+ work_restart = calloc(opt_n_threads, sizeof(*work_restart));
+ if (!work_restart)
+ return 1;
+
work_thr_id = opt_n_threads;
thr = &thr_info[work_thr_id];
thr->id = opt_n_threads;