August 19th, 2003, 07:01 AM
CPU usage in select based server.
I'm programming a kind-of-messenger server based on winsock and select to avoid blocking.
What I do is the classica:
select(0,read,write,exp); //0 Win32
bla bla processing.
I've seen that when running the program consumes almost 50-60 % of CPU, the rest goes to CSRSS.exe. Is it normal? And, what is this CSRSS service?
August 20th, 2003, 02:56 PM
select in a tight loop will consume high CPU on windows, put a small sleep command in there or use the asynch model of WinSock if CPU time is a real issue.
As a general rule-of-thumb, using select() on windows is less optimal than message-pump based asynch system that WinSock has (sends a message when a requested event occured on a socket, instead of polling). On many systems select is implemented in terms on poll and can be quite CPU intensive.
August 20th, 2003, 03:46 PM
Thanks. I don't really know if cpu usage will be an issue or not. I'll try the sleep approach. Anyway, do you know any place where I can find examples of the Winsock event approach? I confess complete ignorance about that!