It is currently Wed Apr 08, 2020 7:15 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ] 
Author Message
 Post subject: nanosecond timer
PostPosted: Fri Aug 28, 2009 10:48 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Aug 21, 2007 2:44 pm
Posts: 430
Location: USA (Cincinnati)
Is it possible to call clock_nanosleep() from PB and, if possible, can someone more adept at C than me provide an example.

http://www.kernel.org/doc/man-pages/online/pages/man2/clock_nanosleep.2.html


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 30, 2009 6:00 am 
Offline
User
User

Joined: Thu Aug 21, 2008 4:19 pm
Posts: 39
Location: Belgium
This is also something on my to do list, thanks for the reminder. PB doesn't recognise this api so the only option is to create a library :?


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 30, 2009 4:27 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Aug 21, 2007 2:44 pm
Posts: 430
Location: USA (Cincinnati)
That's well outside my skillset :oops: so any help will be greatly appreciated.


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Sun Aug 30, 2009 6:28 pm 
first step.

don't work , but this is the good way.

Code:
#CLOCK_REALTIME            = 0
#CLOCK_MONOTONIC           = 1
#CLOCK_PROCESS_CPUTIME_ID  = 2
#CLOCK_THREAD_CPUTIME_ID   = 3
#CLOCK_REALTIME_HR         = 4
#CLOCK_MONOTONIC_HR        = 5


Structure timespec
    tv_sec.i;        /* seconds */
    tv_nsec.i;           /* nanoseconds [0 .. 999999999] */
EndStructure           


ImportC "-lrt"
clock_nanosleep(clockid.i,b.i,c.i,d.i)
EndImport


clock_nanosleep(#CLOCK_MONOTONIC,0,0,0)


Top
  
Reply with quote  
 Post subject:
PostPosted: Wed Sep 02, 2009 2:13 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Aug 21, 2007 2:44 pm
Posts: 430
Location: USA (Cincinnati)
apifunctions.txt in the compilers directory lists nanosleep - perhaps it might be recognized.


Top
 Profile  
Reply with quote  
 Post subject: Re: nanosecond timer
PostPosted: Sun Sep 13, 2009 1:30 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed May 05, 2004 4:04 pm
Posts: 634
Location: Germany
at least to have a working example :wink: :

Code:
;Clock-ID's = Type of clock to use
#CLOCK_REALTIME            = 0
#CLOCK_MONOTONIC           = 1
#CLOCK_PROCESS_CPUTIME_ID  = 2
#CLOCK_THREAD_CPUTIME_ID   = 3
#CLOCK_REALTIME_HR         = 4
#CLOCK_MONOTONIC_HR        = 5

;Flags
#TIMER_ABSTIME=1; if used, the remain variable could be set to #NULL

Structure timespec
    tv_sec.i;           /* seconds */
    tv_nsec.i;         /* nanoseconds [0 .. 999999999] */
EndStructure           

; see  http://www.kernel.org/doc/man-pages/online/pages/man2/clock_nanosleep.2.html
ImportC "-lrt"
clock_nanosleep(clockid.i,flags.i,requested.i,remain.i)
EndImport

time.timespec ; requested nanosleep
rem.timespec; remaining time if interrupted

time\tv_sec=10
time\tv_nsec=666

error=clock_nanosleep(#CLOCK_MONOTONIC,0,@time,@rem)
If error<>0
    ;interupted by signal or error occured
    Debug error
EndIf

_________________
Zip_It V1.1
Image


Last edited by walker on Sun Sep 13, 2009 4:41 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: nanosecond timer
PostPosted: Sun Sep 13, 2009 2:01 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Aug 21, 2007 2:44 pm
Posts: 430
Location: USA (Cincinnati)
walker wrote:
at least to have a working example :wink: :

Thank you. :D


Top
 Profile  
Reply with quote  
 Post subject: Re: nanosecond timer
PostPosted: Sun Sep 13, 2009 4:43 pm 
Offline
Enthusiast
Enthusiast

Joined: Wed May 05, 2004 4:04 pm
Posts: 634
Location: Germany
you're welcome :D
removed a typo in the example ...

_________________
Zip_It V1.1
Image


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 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