logo
down
shadow

Monotonic clock on IRIX


Monotonic clock on IRIX

By : constantine
Date : November 20 2020, 07:00 PM
will be helpful for those in need _rtc is the fastest clock in the system that doesn't wrap. It's a compiler extension, so I think you'll have to use the SGI compilers. If "fairly high-res" is good enough, it will probably be fine; if you need even better resolution, you'll have to hack together a combination of it with CLOCK_SGI_CYCLE.
http://docs.sgi.com/library/tpl/cgi-bin/getdoc.cgi?cmd=getdoc&coll=0650&db=man&fname=3%20RTC
code :


Share : facebook icon twitter icon
Monotonic clock on OSX

Monotonic clock on OSX


By : Zafira Othman
Date : March 29 2020, 07:55 AM
I wish did fix the issue. The Mach kernel provides access to system clocks, out of which at least one (SYSTEM_CLOCK) is advertised by the documentation as being monotonically incrementing.
code :
#include <mach/clock.h>
#include <mach/mach.h>

clock_serv_t cclock;
mach_timespec_t mts;

host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
clock_get_time(cclock, &mts);
mach_port_deallocate(mach_task_self(), cclock);
ns-precision monotonic clock in C on Linux and OS X

ns-precision monotonic clock in C on Linux and OS X


By : Ernst JOSEPH
Date : March 29 2020, 07:55 AM
I hope this helps . clock_gettime(CLOCK_MONOTONIC, ...) is available in Linux but not OS X. The Mach timers are available in OS X but not in Linux.
code :
/* 
This is based on the snippet current_utc_time.c from:
https://gist.github.com/jbenet/1087739

On OS X, compile with: gcc get_monotonic_time.c
   Linux, compile with: gcc get_monotonic_time.c -lrt
*/

#include <time.h>
#include <sys/time.h>
#include <stdio.h>

#ifdef __MACH__
#include <mach/clock.h>
#include <mach/mach.h>
#endif

// Use clock_gettime in linux, clock_get_time in OS X.
void get_monotonic_time(struct timespec *ts){
#ifdef __MACH__
  clock_serv_t cclock;
  mach_timespec_t mts;
  host_get_clock_service(mach_host_self(), SYSTEM_CLOCK, &cclock);
  clock_get_time(cclock, &mts);
  mach_port_deallocate(mach_task_self(), cclock);
  ts->tv_sec = mts.tv_sec;
  ts->tv_nsec = mts.tv_nsec;
#else
  clock_gettime(CLOCK_MONOTONIC, ts);
#endif
}

double get_elapsed_time(struct timespec *before, struct timespec *after){
  double deltat_s  = after->tv_sec - before->tv_sec;
  double deltat_ns = after->tv_nsec - before->tv_nsec;
  return deltat_s + deltat_ns*1e-9;
}

int main(){

  // Do something and time how long it takes.
  struct timespec before, after;
  get_monotonic_time(&before);
  double sum=0.;
  unsigned u;
  for(u=1; u<100000000; u++)
    sum += 1./u/u;
  get_monotonic_time(&after);
  printf("sum = %e\n", sum);
  printf("deltaT = %e s\n", get_elapsed_time(&before,&after));

}
Absolute time using monotonic clock

Absolute time using monotonic clock


By : Sridhar Mamella
Date : March 29 2020, 07:55 AM
may help you . As @IwillnotexistIdonotexist implied, CLOCK_MONOTONIC has no specified starting point and you cannot reliably convert monotonic time to real time.
To quote the clock_gettime manpage, for CLOCK_MONOTONIC:
Get reliable monotonic clock in Java

Get reliable monotonic clock in Java


By : LOK
Date : March 29 2020, 07:55 AM
hope this fix your issue Seems that the posted aspect does not work as expected. Probably because intercepting every single call is too much (I'm not an expert in AOP). I changed it a little to intercept only HelloThread.a and System.out.println calls:
code :
import java.lang.management.ManagementFactory;
import java.lang.management.ThreadMXBean;

aspect Profiler {
  pointcut mainStarting(): execution(public static void main(..));
  pointcut mainEnding(): execution(public static void main(..));
  pointcut methodCallBegin(): (call(* *.a (..)) || call(* *.println (..)));
  pointcut methodCallEnd(): (call(* *.a (..)) || call(* *.println (..)));

  static ThreadMXBean threadBean = ManagementFactory.getThreadMXBean();
  double getTime() {
       return (threadBean.getCurrentThreadCpuTime() / 1000000.0);
  }
  before(): mainStarting() {
       System.out.print("mainStarting: "+Thread.currentThread().getId() 
             + " " + getTime()+"\n");
  }

  after(): mainEnding() {
       System.out.print("mainEnding: "+Thread.currentThread().getId() 
             + " " + getTime()+"\n");
  }

  before(): methodCallBegin() {
      System.out.print("methodCallBegin: "+Thread.currentThread().getId() 
             + " " + getTime()+"\n");
  }

  after(): methodCallEnd() {
      System.out.print("methodCallEnd: "+Thread.currentThread().getId() 
             + " " + getTime()+"\n");
  }
}
mainStarting: 1 93.6006
methodCallBegin: 1 93.6006
methodCallEnd: 1 93.6006
methodCallBegin: 1 93.6006
Hello
methodCallEnd: 1 93.6006
mainEnding: 1 93.6006
public static void main(String args[]) throws Exception {
    HelloThread ht = new HelloThread();
    int b = ht.a(1);
    System.out.println("Hello");
}

int a(int x) {
    for (int i = 0; i < 1000000; i++) {
        x = x * 5;
    }
    return x;
}
mainStarting: 1 93.6006
methodCallBegin: 1 93.6006
methodCallEnd: 1 109.2007
methodCallBegin: 1 109.2007
Hello
methodCallEnd: 1 109.2007
mainEnding: 1 109.2007
iOS real monotonic clock other than mach_absolute_time()

iOS real monotonic clock other than mach_absolute_time()


By : Gnana Darshan
Date : March 29 2020, 07:55 AM
this will help This does the trick:
See: Getting iOS system uptime, that doesn't pause when asleep
Related Posts Related Posts :
  • Efficient way to find divisibility
  • Whats the fastest, portable way to hash pointers we know are pointer aligned to a fixed size int?
  • Why does my summation program behaves weird?
  • How to determine values saved on the stack?
  • Thread scheduling C
  • C - converting to 2s complement
  • wireless networks c program
  • From where does the uboot get the information about flash, RTC, RAM in uboot/kernel development
  • printf behaviour in C
  • Measure size and way-order of L1 and L2 caches
  • Efficient copy of entire directory
  • Efficient way to create/unpack large bitfields in C?
  • getnameinfo prototype asks for sockaddr not sockaddr_in?
  • Linked List Sorting with Strings In C
  • Typecasting a floating value or using the math.h floor* functions?
  • Problem implementing sorting algorithm in C with an array of structs
  • How to copy a ram_base file to disk efficiently
  • How to fix casting a pointer to an integer?
  • How to round floating point numbers to the nearest integer in C?
  • PIC C - Sending 200 values over USB, but it only sends 25 or so of them
  • How do you return a string from a function correctly in Dynamic C?
  • setsockopt (sys/socket.h)
  • How to make C program wait (on Linux)?
  • i find a problem using atoi() method in ansi c?
  • Why is this array being initialized in an odd way?
  • How to execute commands in chroot?
  • Microsecond (or one ms) time resolution on an embedded device (Linux Kernel)
  • Question about variable definitions in functions
  • SMTP on C: STARTTLS via OpenSSL
  • fetch value of ipaddress
  • Binary expressions in C
  • Why do char * and char ** have the same value?
  • problem in allocating kernel memory by malloc() from user space?
  • dangling pointer, reason for value change after free()?
  • How to compile C program with multiple files in Xcode
  • Can you make an incrementing compiler constant?
  • Reading data from text file in C
  • SQLite's test code to production code ratio
  • Displaying an inverted pyramid of asterisks
  • sd spi mode in C language
  • printf("%2d") in C programming
  • Add a certain number of bytes to a void pointer in C
  • How should I protect against hard link attacks?
  • What's the difference between unsigned long/long/int in c/c++?
  • Get an input from keyboard without 'return' in C
  • How to convert if to switch-case in c
  • C: swapping two pointer value
  • What does \x mean in c/c++?
  • run a command line argument prog
  • Pass a dynamic structure by reference? [C]
  • C + GUI + Mac OS
  • strstr matching first occurrence in c
  • Why does it NOT give a segmentation violation?
  • Usage of EOF in C
  • Linux Bluetooth programming
  • program that writes the even and odd numbers
  • C Socket Programming, problems with select() and fd_set
  • Ways to divide the high/low byte from a 16bit address?
  • Single line comment - unable to compile on solaris
  • Linking the Linker script file to source code
  • shadow
    Privacy Policy - Terms - Contact Us © 35dp-dentalpractice.co.uk