Last active
June 25, 2016 18:48
-
-
Save moyix/a49ae005cbcdc2853863a6c461904b73 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.global do_rdrand | |
/* Signature: uint32_t do_rdrand(void); */ | |
do_rdrand: | |
.Lrdrand_retry: | |
rdrand %rax | |
jc .Lrdrand_retry /* Fail? */ | |
ret |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
#include <stdint.h> | |
#include <pthread.h> | |
uint32_t do_rdrand(void); | |
void * threadfunc(void *unused) { | |
printf("Value: %08x\n", do_rdrand()); | |
return NULL; | |
} | |
int main(int argc, char **argv) { | |
int nThread = atoi(argv[1]); | |
pthread_t *threads = (pthread_t *) malloc(nThread * sizeof(pthread_t)); | |
for (int i = 0; i < nThread; i++) { | |
pthread_create(&threads[i], NULL, threadfunc, NULL); | |
} | |
for (int i = 0; i < nThread; i++) { | |
pthread_join(threads[i], NULL); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment