Giter Club home page Giter Club logo

posixclock.jl's Introduction

POSIXClock.jl

Julia bindings for POSIX Clock.

Installation

From Julia REPL, run

Pkg.clone("https://github.com/ibadr/POSIXClock.jl")

Scope

The initial scope of this Julia package is to expose PREEMPT_RT capabilities to Julia users. The long-term goal is to provide cross-platform wrapping of POSIX clock_*() functions similar to node-posix-clock and posix-timer.

Usage

For real-time performance, it is recommended to use in-place operations and to pre-allocate all needed variables prior to entering the real-time section. Also, use CLOCK_MONOTONIC in order to avoid jumps related to changing the system time. Typical usage example is as follows

import POSIXClock; CLK=POSIXClock

function main() # it is important to wrap your code in a function to avoid
    # unnecessary memory allocations
  t=CLK.timespec(0,0) # pre-allocate
  gc_enable(false) # temporarily disable the GC
  # enter real-time section
  CLK.gettime!(t,CLK.CLOCK_MONOTONIC) # get current Linux time
  @time for n in 1:10000
    CLK.nanosleep!(t,300000) # increment t by 300us and sleep until that time (absolute time)
  end # the loop time should be around 3 sec
  # exit real-time section
  gc_enable(true) # enable the GC
end

main() # execute the main function

Examples

See the examples directory. The next example latency plot was obtained by running Julia as a real-time process on PREEMPT_RT Linux kernel, then including the "rt_histogram.jl" file from the examples folder. This example plot was generated on Ubuntu 16.04 running a custrom PREEMPT_RT Linux kernel v4.4.12-rt19 with CPU frequency scaling disabled. Julia was run on a dedicated processor core (using taskset & isolcpus=1 kernel command line) on a dual-core Intel Celeron processor based on SandyBridge architecture, with elevated SCHED_FIFO priority 50 (using chrt). The first CPU core was stress-loaded using the stress utility.

Latency

posixclock.jl's People

Contributors

ibadr avatar

Watchers

James Cloos avatar Marwan Abdellah avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.