|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
CPU usage in select based server.
Hi all,
I'm programming a kind-of-messenger server based on winsock and select to avoid blocking. What I do is the classica: while(1){ 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? Thanks. |
|
#2
|
|||
|
|||
|
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. |
|
#3
|
|||
|
|||
|
Hi,
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! |
![]() |
| Viewing: Dev Shed Forums > Computer Hardware > CPUs > CPU usage in select based server. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|