![]() |
|
|
#1289 |
|
Romulan Interpreter
Jun 2011
Thailand
227008 Posts |
Sorry, I am temporary out of the game, half of the resources are totally busy, and the other half are split down to pieces and spread through all the house, fact that is maximum pissing off Mrs LaurV... (switching to liquid cooling).
Last fiddled with by LaurV on 2012-05-16 at 02:52 |
|
|
|
|
|
#1290 |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
Could someone help me understand what this code does?
Code:
int
_kbhit (void)
{
struct termios oldt, newt;
int ch;
int oldf;
tcgetattr (STDIN_FILENO, &oldt);
newt = oldt;
newt.c_lflag &= ~(ICANON | ECHO);
tcsetattr (STDIN_FILENO, TCSANOW, &newt);
oldf = fcntl (STDIN_FILENO, F_GETFL, 0);
fcntl (STDIN_FILENO, F_SETFL, oldf | O_NONBLOCK);
ch = getchar ();
tcsetattr (STDIN_FILENO, TCSANOW, &oldt);
fcntl (STDIN_FILENO, F_SETFL, oldf);
if (ch != EOF)
{
ungetc (ch, stdin);
return 1;
}
return 0;
}
|
|
|
|
|
|
#1291 |
|
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
224318 Posts |
Looks like it checks if a key was pressed, and if so, put it back in the queue but signal the caller that a character can now be retrieved.
P.S. A copy of the normal term i/o handler is created except it is now non-blocking. If you ask for a char from normal code, it will sit doing nothing _until_ you press the key. Here, this routine will report to the caller - "there was no activity, carry on". Last fiddled with by Batalov on 2012-05-16 at 23:20 |
|
|
|
|
|
#1292 | |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
Quote:
Code:
char c = getchar(); if(c!=EOF) { ungetc(c, stdin); return 1;} else return 0;
|
|
|
|
|
|
|
#1293 | |
|
Romulan Interpreter
Jun 2011
Thailand
100101110000002 Posts |
Quote:
The original code does a lot of work to modify the behavior of the getchar() routine to return immediately in case no key was already pressed, without waiting for the key, and if a key was pressed, to get its scan code, (accepting key combinations, like CTRL+ALT+F12), and terminate if ctrl+c was pressed. After the key is read, the old behavior (waiting for the key) is restored. Se for details here and here (follow the fork link in that post). Last fiddled with by LaurV on 2012-05-17 at 02:13 |
|
|
|
|
|
|
#1294 | |
|
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
3·29·83 Posts |
Quote:
![]() I swear I'm not usually this dumb ![]() Edit: It seems to be formulaic enough that I can reuse it without a problem; it seems that actually understanding it will require quite a bit of time reading through 'man termios', which I'll do later. Thanks for the help, B&L. Last fiddled with by Dubslow on 2012-05-17 at 03:58 |
|
|
|
|
|
|
#1296 |
|
"Serge"
Mar 2008
Phi(4,2^7658614+1)/2
251916 Posts |
{sarcasm}
No, clearly, to make things right you should pass the residue to Dubslow, so that he could submit it as a CUDALucas residue. After all, the error was now corrected! {/sarcasm} Seriously, if you don't want people to make suggestions like the above you could PM each other. OTOH, if you value other people's opinions, you should simply let the server do its job of tallying correct and incorrect residues and enforce impartiality by assigning the double-check to a random Dudes, grow up already - these are just numbers! You voluntarily turn yourselves into human computers. |
|
|
|
|
|
#1297 | |
|
"Jerry"
Nov 2011
Vancouver, WA
112310 Posts |
Quote:
|
|
|
|
|
|
|
#1298 |
|
P90 years forever!
Aug 2002
Yeehaw, FL
19·397 Posts |
Submit the successful triple-check first.
If you submit the bad double-check first, then there is a window where the server will make the exponent available to some poor unsuspecting user for a triple-check. |
|
|
|
![]() |
| Thread Tools | |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Don't DC/LL them with CudaLucas | LaurV | Data | 131 | 2017-05-02 18:41 |
| CUDALucas / cuFFT Performance on CUDA 7 / 7.5 / 8 | Brain | GPU Computing | 13 | 2016-02-19 15:53 |
| CUDALucas: which binary to use? | Karl M Johnson | GPU Computing | 15 | 2015-10-13 04:44 |
| settings for cudaLucas | fairsky | GPU Computing | 11 | 2013-11-03 02:08 |
| Trying to run CUDALucas on Windows 8 CP | Rodrigo | GPU Computing | 12 | 2012-03-07 23:20 |