Hi,writing the image to disk wastes 10 seconds by waiting for 0.1s a hundred times.
The problem is the key_pressed function. It always attempts to read a char from the terminal with a timeout of 1 decisecond. It's better to poll the terminal without unnecessary waiting.
On my laptop the improvement is very noticeable if I enable compression. With compression disabled, the effect is not so obvious, because disk throughput is the bottleneck.
Michal
Index: splash.c =================================================================== RCS file: /cvsroot/suspend/suspend/splash.c,v retrieving revision 1.5 diff -u -r1.5 splash.c --- splash.c 10 Jan 2007 14:16:45 -0000 1.5 +++ splash.c 17 Jan 2007 19:33:15 -0000 @@ -41,8 +41,6 @@ ret = tcgetattr(0, oldtrm); if (!ret) { *newtrm = *oldtrm; - newtrm->c_cc[VMIN] = 0; - newtrm->c_cc[VTIME] = 1; newtrm->c_iflag = IGNBRK | IGNPAR | ICRNL | IMAXBEL; newtrm->c_lflag = 0; ret = tcsetattr(0, TCSANOW, newtrm); @@ -54,6 +52,14 @@ static int key_pressed(const char key) { char c; + fd_set fds; + struct timeval tv = {0, 0}; + + FD_ZERO(&fds); + FD_SET(0, &fds); + if (select(1, &fds, NULL, NULL, &tv) <= 0) + return 0; + if (read(0, &c, 1) > 0 && c == key) return 1;
------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________ Suspend-devel mailing list Suspend-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/suspend-devel