Last active
June 14, 2020 12:30
-
-
Save disconnect3d/4c87c15fc03009a47fa703b7379f6682 to your computer and use it in GitHub Desktop.
An attempt to make RDRAND step to fail
This file contains hidden or 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
// g++ spam.cpp -O3 -lpthread -std=c++14 && ./a.out | |
#include <stdio.h> | |
#include <stdint.h> | |
#include <thread> | |
#include <immintrin.h> | |
__attribute__ ((target ("rdrnd"))) | |
void exec(int id) { | |
printf("[thread %d]\n", id); | |
long long unsigned int i=0, num=0; | |
while (1) { | |
if (_rdrand64_step(&num) != 1) | |
abort(); | |
} | |
} | |
int main() { | |
#define N 16 | |
std::thread t[N]; | |
for (int i=0; i<N; ++i) | |
t[i] = std::thread(exec, i); | |
exec(N+1); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Another attempt - a more tight loop (thx to a friend of mine):
...still no failures.