It is currently Thu Jun 20, 2013 1:02 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: High Resolution Timer Research
PostPosted: Mon Mar 05, 2012 8:01 pm 
Offline
Addict
Addict

Joined: Sun Aug 08, 2004 5:21 am
Posts: 1109
Location: Netherlands
nanosleep does exist on both Linux and OS X if I'm correct
On OS X
Code:
Structure timespec
  tv_sec.i
  tv_nsec.l
EndStructure
   
ImportC ""
  nanosleep(*req.timespec, *rem.timespec = #Null)
EndImport

pause.timespec\tv_nsec = 300000
nanosleep(@pause)

On Linux you probably need to specify a library for ImportC and it's not very accurate.
There's also clock_delay_until(deadline.q)


Top
 Profile  
 
 Post subject: Re: High Resolution Timer Research
PostPosted: Mon Mar 05, 2012 8:14 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Wed Oct 22, 2003 2:51 am
Posts: 734
Location: Canada
It's better and more safe to implement it this way :

Code:
Procedure NanoDelay(Nanoseconds.l)
 
  If Nanoseconds > 0 And Nanoseconds <= 999999999
    req.timespec\tv_nsec = Nanoseconds
    ProcedureReturn nanosleep(@req, #Null)
  Else
    ProcedureReturn -1
  EndIf
 
EndProcedure


But the Sleep will always be a little bit longer than expected. Maybe this is due to PureBasic Procedure calling time or the CPU load or both.

Best regards
Guimauve


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 17 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye