From: "Iñaki Baz Castillo" Date: 2008-03-27T07:49:14+09:00 Subject: Re: "loop do IO.select([io], nil, nil)" eats 95% of CPU, any other way? El Miércoles, 26 de Marzo de 2008, John Carter escribió: > Hmm.From the "man select" page... > > timeout is an upper bound on the amount of time elapsed before > select() returns. It may be zero, causing select() to return > immediately. (This is useful for polling.) If timeout is NULL > (no timeout), select() can block indefinitely. > > My guess is you have one too few nil's in there and the default timeout is > 0 not nil. Yes, true, with "strace" I see: ... sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 select(4, [3], [], [], {0, 0}) = 0 (Timeout) <--- sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 sigprocmask(SIG_BLOCK, NULL, []) = 0 ... but I've tryed with all the values in the 4º parameter of "IO.select": IO.select([io], nil, nil, 0) IO.select([io], nil, nil, nil) IO.select([io], nil, nil, X) and nothing changes, in all cases I see the same with "strace". ¿?¿ > to discover why linux is such a great place to develop on.... you can > _always_ find out what is really going on with any program. Sure I use Linux... what else? XD > As a little side comment... You can _always_ take a program written > around a select & state machine and make it multi-threaded doing > blocking I/O or conversely refactor a multi-threaded app into a select > based state machine. Of course I need to read a lot about IO methods :) Thanks a lot. -- Iñaki Baz Castillo