Skip to content

Instantly share code, notes, and snippets.

@antirez
Created February 5, 2010 23:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save antirez/296382 to your computer and use it in GitHub Desktop.
Save antirez/296382 to your computer and use it in GitHub Desktop.
/* The following is a simple program to check for memory corrections in
* DRAM with ECC switched off. Accordingly to recend large scale studies
* such as http://www.cs.toronto.edu/~bianca/papers/sigmetrics09.pdf
* the error rate is of 25,000-75,000 errors per billion hours per Mbit.
*
* If this is true you should see at least one error after a few days
* running this program at max in a computer without ECC.
*
* Compile with: gcc -O2 -Wall -W -o dramerr dramerr.c
*
* For feedbacks: antirez@gmail.com */
#include <stdio.h>
#include <stdlib.h>
/* It's more likely for a 0 to become 1 or the reverse, or it's just the
* same? I don't know so I'll fill with 1010101010101010101.... */
#define PATTERN 0xAA
#define MEGABITS 8192 /* 8192 megabits are 1 gigabyte of memory */
#define BYTESPERMEGABIT 131072
int main(void) {
unsigned char *mem = malloc(MEGABITS*BYTESPERMEGABIT);
long j;
if (mem == NULL) {
printf("Sorry, can't allocate %d megabits of memory\n", MEGABITS);
exit(1);
}
for (j = 0; j < MEGABITS*BYTESPERMEGABIT; j++)
mem[j] = PATTERN;
while(1) {
for (j = 0; j < MEGABITS*BYTESPERMEGABIT; j++) {
if (mem[j] != PATTERN) {
printf("Error detected at byte %ld: %02x instead of %02x\n",
j, mem[j], PATTERN);
exit(1);
}
}
printf(".");
fflush(stdout);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment