//---------------------------------------------------------------- // grabber2.cpp // // This is a faster version of the 'grabber1.cpp' program; // it uses a greatly reduced number of system-calls to our // 'vram.c' device-driver, as recommended by many students // in their answer to Question IV on Midterm II. It takes // advantage of that driver's ability to return 4096 bytes // (1024 pixels) in a single read-operation. // // programmer: ALLAN CRUSE // written on: 13 MAR 2005 //---------------------------------------------------------------- #include // for open() #include // for read(), write(), close() int main( void ) { int src = open( "/dev/vram", O_RDONLY ); int dst = open( "image.dat", O_CREAT | O_WRONLY | O_TRUNC, 0666 ); int res = 1280 * 1024; for (int i = 0; i < res/1024; i++) { unsigned long pel[1024]; read( src, &pel, sizeof( pel ) ); write( dst, &pel, sizeof( pel ) ); } close( dst ); close( src ); }