2

I have a application in which I have to sleep for a very short time (in order of few micro seconds ). Fortunately my Linux kernel 2.8.* supports high res timers.

I have 2 options to sleep now

  1. nanosleep
  2. select() with a timeout.

I choose to use select() as it is quite portable. Does select() use the normal kernel timers ( jiffies) or it uses the hi res timers ?

Can this provide sleep functionality in order of microseconds ?

Abhijeet Kasurde
  • 3,937
  • 1
  • 24
  • 33
KodeWarrior
  • 3,538
  • 3
  • 26
  • 40
  • temme abt it. One of the perks of working in a huge firm :P – KodeWarrior Feb 20 '13 at 22:29
  • No, seriously, wha kernel are you using ? – cnicutar Feb 20 '13 at 23:47
  • Sorry. mis-interpreted your comment. Kernel version 2.6.18-128.1.6.el5 – KodeWarrior Feb 21 '13 at 19:58
  • I think that version of the kernel already supports ``pselect`` and probably also your libc, so if you really want a high precision you can use it. One of the differences between ``select`` and ``pselect``is that the later offers more precision. Either than this, I actually don't know the answer to your question :\ ``select`` receives a ``struct timeval`` which has a component for microseconds, which leads me to believe that if your system supports it can offer microsecond precision. – Fred Feb 23 '13 at 19:49

0 Answers0