mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Provide a ms based sleep function that uses nanosleep to avoid the inaccuracy of usleep on SMP systems.
This commit is contained in:
parent
390d77a202
commit
3271be145f
2
miner.h
2
miner.h
@ -426,7 +426,7 @@ struct thr_info {
|
|||||||
extern int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
|
extern int thr_info_create(struct thr_info *thr, pthread_attr_t *attr, void *(*start) (void *), void *arg);
|
||||||
extern void thr_info_cancel(struct thr_info *thr);
|
extern void thr_info_cancel(struct thr_info *thr);
|
||||||
extern void thr_info_freeze(struct thr_info *thr);
|
extern void thr_info_freeze(struct thr_info *thr);
|
||||||
|
extern void nmsleep(unsigned int msecs);
|
||||||
|
|
||||||
struct string_elist {
|
struct string_elist {
|
||||||
char *string;
|
char *string;
|
||||||
|
11
util.c
11
util.c
@ -687,3 +687,14 @@ void thr_info_cancel(struct thr_info *thr)
|
|||||||
PTH(thr) = 0L;
|
PTH(thr) = 0L;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Provide a ms based sleep that uses nanosleep to avoid poor usleep accuracy
|
||||||
|
* on SMP machines */
|
||||||
|
void nmsleep(unsigned int msecs)
|
||||||
|
{
|
||||||
|
struct timespec twait;
|
||||||
|
|
||||||
|
twait.tv_sec = msecs / 1000;
|
||||||
|
twait.tv_nsec = (uint64_t)(msecs * 1000000) - (uint64_t)(twait.tv_sec / 1000000000);
|
||||||
|
nanosleep(&twait, NULL);
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user