Browse Source

find_work() to find work in devices work queue

nfactor-troky
Kano 12 years ago
parent
commit
b3ae0f168e
  1. 18
      cgminer.c
  2. 1
      miner.h

18
cgminer.c

@ -5786,6 +5786,24 @@ struct work *get_queued(struct cgpu_info *cgpu)
return ret; return ret;
} }
struct work *find_work(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen)
{
struct work *work, *tmp, *ret = NULL;
rd_lock(&cgpu->qlock);
HASH_ITER(hh, cgpu->queued_work, work, tmp) {
if (work->queued &&
memcmp(work->midstate, midstate, midstatelen) == 0 &&
memcmp(work->data + offset, data, datalen) == 0) {
ret = work;
break;
}
}
rd_unlock(&cgpu->qlock);
return ret;
}
/* This function should be used by queued device drivers when they're sure /* This function should be used by queued device drivers when they're sure
* the work struct is no longer in use. */ * the work struct is no longer in use. */
void work_completed(struct cgpu_info *cgpu, struct work *work) void work_completed(struct cgpu_info *cgpu, struct work *work)

1
miner.h

@ -1183,6 +1183,7 @@ struct modminer_fpga_state {
extern void get_datestamp(char *, struct timeval *); extern void get_datestamp(char *, struct timeval *);
extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce); extern void submit_nonce(struct thr_info *thr, struct work *work, uint32_t nonce);
extern struct work *get_queued(struct cgpu_info *cgpu); extern struct work *get_queued(struct cgpu_info *cgpu);
extern struct work *find_work(struct cgpu_info *cgpu, char *midstate, size_t midstatelen, char *data, int offset, size_t datalen);
extern void work_completed(struct cgpu_info *cgpu, struct work *work); extern void work_completed(struct cgpu_info *cgpu, struct work *work);
extern void hash_queued_work(struct thr_info *mythr); extern void hash_queued_work(struct thr_info *mythr);
extern void tailsprintf(char *f, const char *fmt, ...); extern void tailsprintf(char *f, const char *fmt, ...);

Loading…
Cancel
Save