release CPU tme

I'm writing a network server in C++ for Linux.  I have a continuous loop around my non-blocking accept() call because I need to run administrative functions from time to time.

The problem is that this continuously running loop munches all available CPU time.  What I need is a function that will release time to the system to schedule to other processes (kinda like sleep() but with millisecond resolution)

LVL 1
shiversAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
use 'usleep()', which allows suspending a process with a microsecond resolution - here's the manpage:

 #include <unistd.h>

   int usleep(
        useconds_t useconds);



STANDARDS


  Interfaces documented on this reference page conform to industry standards
  as follows:

  usleep():  XPG4-UNIX

  Refer to the standards(5) reference page for more information about
  industry standards and associated tags.



PARAMETERS


  useconds  Specifies the number of microseconds to sleep.



DESCRIPTION


  The usleep() function suspends the current process from execution for the
  number of microseconds specified by the useconds parameter.  Because of
  other activity in the system, or because of the time spent in processing
  the call, the actual suspension time might be longer than specified.

  The useconds parameter must be less than 1,000,000.  If the value of
  useconds is 0 (zero), the usleep() function has no effect.

  In a multithreaded environment, the sleep() function is redefined to
  suspend the calling thread.






RETURN VALUES


  On successful completion, the usleep() function returns 0 (zero).
  Otherwise, it returns -1 and sets errno to indicate the error.




ERRORS


  The usleep() function sets errno to the specified values for the following
  conditions:

  [EINVAL]  The interval specified in the useconds parameter exceeds
          1,000,000 microseconds.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shiversAuthor Commented:
luvly, thanx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.