Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #include <unistd.h>
- // USAGE: soft-error size
- // size is in mebibytes
- // default 128 MB if not specified
- int main( int argc, char *argv[] )
- {
- int size = 128;
- if ( argc == 2 )
- size = atoi( argv[1] );
- else if ( argc != 1 )
- {
- fprintf( stderr, "Usage: %s [size_in_MB]\n", argv[0] );
- return 1;
- }
- int bsize = size * 1024 * 1024;
- unsigned char * mp = new unsigned char[bsize];
- if ( mp == 0 )
- {
- fprintf( stderr, "Error: cannot allocate %d bytes.\n", bsize );
- return 2;
- }
- for ( int i = 0; i < bsize; ++i )
- mp[i] = 0x55;
- long start_time = time(0);
- long error_count = 0;
- while ( 1 )
- {
- long current_time = time(0);
- for ( int i = 0; i < bsize; ++i )
- if ( mp[i] != 0x55 )
- {
- printf( "%d seconds, byte %i, got 0x%x, expected 0x55\n", current_time - start_time, i, mp[i] );
- FILE * fp = fopen( "error.log", "a" );
- if ( fp )
- {
- fprintf( fp, "%d seconds, byte %i, got 0x%x, expected 0x55\n", current_time - start_time, i, mp[i] );
- fclose( fp );
- }
- ++error_count;
- mp[i] = 0x55;
- }
- sleep(60);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement