<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Recent changes to Time</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>Recent changes to Time</description><atom:link href="https://sourceforge.net/p/madara/wiki/Time/feed" rel="self"/><language>en</language><lastBuildDate>Sat, 24 Mar 2018 05:28:34 -0000</lastBuildDate><atom:link href="https://sourceforge.net/p/madara/wiki/Time/feed" rel="self" type="application/rss+xml"/><item><title>Time modified by James Edmondson</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v6
+++ v7
@@ -68,6 +68,6 @@

 ~~~~~~

-&lt;img alt="" rel="nofollow" src="https://imgur.com/zBz8Oxp.png" title="" width="700"/&gt;
+&lt;img alt="" rel="nofollow" src="https://imgur.com/bAJcSVv.png" title="" width="700"/&gt;

 The Threader enforces epochs to limit bursty behavior and control the execution of tasks. If a task runs over its epoch, it is not necessarily immediately run but instead run at the appropriate epoch as shown in the figure above.
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">James Edmondson</dc:creator><pubDate>Sat, 24 Mar 2018 05:28:34 -0000</pubDate><guid>https://sourceforge.net08cb71a7391a07a4c0fefa4738a03290e6a935d3</guid></item><item><title>Time modified by James Edmondson</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v5
+++ v6
@@ -26,6 +26,7 @@
 Similarly, developers can use time (NULL) or any other standard time keeping mechanism and put the result of such operations inside of the knowledge base for later retrieval and usage.

 *MADARA also provides standard get time and sleep related functions, including:*
+
 * Sleep: [madara::utility::sleep (double seconds)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#a4e39cc1be95c5d37764e81b2f7f386b3): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in wall clock time. 
 * Sleep:  [madara::utility::sleep (ACE_Time_Value)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ad4e12fb49ead09091eed559c5318e2a9): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in ACE Time Value format (lots of options for specifying in nanoseconds, microseconds, milliseconds, etc.)
 * Timestamp: [madara::utility::get_time (void)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ab842b817b5f645f774b389bed04c8c11): returns time of day in nanoseconds (useful for duration timestamps). 
&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">James Edmondson</dc:creator><pubDate>Fri, 23 Mar 2018 22:01:53 -0000</pubDate><guid>https://sourceforge.net8b6ff8c3963bc2f120a02b5238216b972ed8b7d4</guid></item><item><title>Time modified by James Edmondson</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v4
+++ v5
@@ -2,7 +2,7 @@

 ----

-**Time Utilities**
+# Time Utilities

 ACE: Everything available in ACE including nanosecond timers, durations, timestamps, portable wallclock time, etc. is fully supported in MADARA. ACE is a prerequisite, so you inherit all of the portable OS time utilities from there.

@@ -23,11 +23,12 @@
 timer.elapsed_time (duration);
 ~~~~~~

+Similarly, developers can use time (NULL) or any other standard time keeping mechanism and put the result of such operations inside of the knowledge base for later retrieval and usage.

 *MADARA also provides standard get time and sleep related functions, including:*
-* [madara::utility::sleep (double seconds)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#a4e39cc1be95c5d37764e81b2f7f386b3): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in wall clock time. 
-* [madara::utility::sleep (ACE_Time_Value)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ad4e12fb49ead09091eed559c5318e2a9): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in ACE Time Value format (lots of options for specifying in nanoseconds, microseconds, milliseconds, etc.)
-* [madara::utility::get_time (void)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ab842b817b5f645f774b389bed04c8c11): returns time of day in nanoseconds (useful for duration timestamps). 
+* Sleep: [madara::utility::sleep (double seconds)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#a4e39cc1be95c5d37764e81b2f7f386b3): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in wall clock time. 
+* Sleep:  [madara::utility::sleep (ACE_Time_Value)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ad4e12fb49ead09091eed559c5318e2a9): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in ACE Time Value format (lots of options for specifying in nanoseconds, microseconds, milliseconds, etc.)
+* Timestamp: [madara::utility::get_time (void)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ab842b817b5f645f774b389bed04c8c11): returns time of day in nanoseconds (useful for duration timestamps). 

 *MADARA has time system calls inside of the KaRL scripting language:* [Full List of System Calls](https://sourceforge.net/p/madara/code/ci/master/tree/docs/system_calls.txt)
 ~~~~~~
@@ -46,9 +47,11 @@
   spent sleeping in seconds.
 ~~~~~~

+The [madara::knowledge::KnowledgeBase](http://madara.sourceforge.net/docs/cpp/da/d1c/classmadara_1_1knowledge_1_1KnowledgeBase.html)  keeps a Lamport clock for itself and also keeps individual Lamport clocks for each variable within the KnowledgeBase. These clocks are used to ensure consistency of knowledge during updates from external agents. To access these Lamport clocks, users should use the KaRL system calls noted above.
+
 ----

-**Threads**
+# Thread Timing Control

 The main manager of threads and time related to thread execution is the [madara::threads::Threader](http://madara.sourceforge.net/docs/cpp/d8/de5/classmadara_1_1threads_1_1Threader.html) class. To get predictable executions of threads that subclass from [madara::threads::BaseThread](http://madara.sourceforge.net/docs/cpp/de/dcd/classmadara_1_1threads_1_1BaseThread.html), you use the `Threader::run` with a provided hertz rate (specified as a double).

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">James Edmondson</dc:creator><pubDate>Fri, 23 Mar 2018 21:59:35 -0000</pubDate><guid>https://sourceforge.net61c95941624340a630b3b3a16a7c21b131ed3312</guid></item><item><title>Time modified by James Edmondson</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v3
+++ v4
@@ -6,13 +6,45 @@

 ACE: Everything available in ACE including nanosecond timers, durations, timestamps, portable wallclock time, etc. is fully supported in MADARA. ACE is a prerequisite, so you inherit all of the portable OS time utilities from there.

+An example usage of ACE time for nanosecond resolution timers and durations can be seen in the following:
+~~~~~~
+#include "ace/High_Res_Timer.h"
+
+// ACE timer and nanosecond duration
+ACE_High_Res_Timer timer;
+ACE_hrtime_t duration;
+
+// start the timer, do some work, stop the timer.
+timer.start ();
+...
+timer.stop ();
+
+// calculate duration in nanoseconds. Can also convert from the duration to an ACE_Time_Value
+timer.elapsed_time (duration);
+~~~~~~
+
+
 *MADARA also provides standard get time and sleep related functions, including:*
 * [madara::utility::sleep (double seconds)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#a4e39cc1be95c5d37764e81b2f7f386b3): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in wall clock time. 
-* [madara::utility::sleep (ACE_Time_Value)(http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ad4e12fb49ead09091eed559c5318e2a9): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in ACE Time Value format (lots of options for specifying in nanoseconds, microseconds, milliseconds, etc.)
+* [madara::utility::sleep (ACE_Time_Value)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ad4e12fb49ead09091eed559c5318e2a9): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in ACE Time Value format (lots of options for specifying in nanoseconds, microseconds, milliseconds, etc.)
 * [madara::utility::get_time (void)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ab842b817b5f645f774b389bed04c8c11): returns time of day in nanoseconds (useful for duration timestamps). 

-*MADARA has time functions inside of the KaRL scripting language:*
-* 
+*MADARA has time system calls inside of the KaRL scripting language:* [Full List of System Calls](https://sourceforge.net/p/madara/code/ci/master/tree/docs/system_calls.txt)
+~~~~~~
+#get_clock () or #get_clock (variable):
+  Returns either the system clock or the variable clock. Note that
+  this is a Lamport clock value and not a wall time value.
+
+#get_time () or #get_time_ns() or #get_time_nano():
+  Returns wall clock time on the local machine in nanoseconds.
+
+#get_time_seconds () or #get_time_s ():
+  Returns wall clock time on the local machine in seconds.
+
+#sleep (double time_to_sleep in s):
+  Sleeps for at least the specified time and returns time
+  spent sleeping in seconds.
+~~~~~~

 ----

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">James Edmondson</dc:creator><pubDate>Fri, 23 Mar 2018 21:53:33 -0000</pubDate><guid>https://sourceforge.net40e02176d93a620a6c214130cb907ab239441f60</guid></item><item><title>Time modified by James Edmondson</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v2
+++ v3
@@ -6,7 +6,13 @@

 ACE: Everything available in ACE including nanosecond timers, durations, timestamps, portable wallclock time, etc. is fully supported in MADARA. ACE is a prerequisite, so you inherit all of the portable OS time utilities from there.

-MADARA also provides standard get time functions
+*MADARA also provides standard get time and sleep related functions, including:*
+* [madara::utility::sleep (double seconds)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#a4e39cc1be95c5d37764e81b2f7f386b3): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in wall clock time. 
+* [madara::utility::sleep (ACE_Time_Value)(http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ad4e12fb49ead09091eed559c5318e2a9): hard sleep that ignores OS interrupts and guarantees a sleep as long as the time specified in ACE Time Value format (lots of options for specifying in nanoseconds, microseconds, milliseconds, etc.)
+* [madara::utility::get_time (void)](http://madara.sourceforge.net/docs/cpp/de/d04/namespacemadara_1_1utility.html#ab842b817b5f645f774b389bed04c8c11): returns time of day in nanoseconds (useful for duration timestamps). 
+
+*MADARA has time functions inside of the KaRL scripting language:*
+* 

 ----

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">James Edmondson</dc:creator><pubDate>Fri, 23 Mar 2018 21:45:48 -0000</pubDate><guid>https://sourceforge.net07f4593757c7c95c11bba7c3c5e848d3d4d2ab6b</guid></item><item><title>Time modified by James Edmondson</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>&lt;div class="markdown_content"&gt;&lt;pre&gt;--- v1
+++ v2
@@ -17,7 +17,7 @@
 ~~~~~~
 madara::threads::Threader threader;

-// run threads at 50hz and 1hz
+// run threads at 10hz and 1hz
 threader.run (10.0, "analyzer", new AnalyzerThread ());
 threader.run (1.0, "enforcer", new EnforcerThread ());

&lt;/pre&gt;
&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">James Edmondson</dc:creator><pubDate>Fri, 23 Mar 2018 21:39:12 -0000</pubDate><guid>https://sourceforge.net0d2ec5eefe2ea2aec590505f528f87609f556566</guid></item><item><title>Time modified by James Edmondson</title><link>https://sourceforge.net/p/madara/wiki/Time/</link><description>&lt;div class="markdown_content"&gt;&lt;p&gt;MADARA has many different time mechanisms and quality-of-service mechanisms that refer to or manage time-based events or actions. In this wiki page, we'll try to discuss mechanisms available to developers concerning management, control, recording, and reacting to time.&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;&lt;strong&gt;Time Utilities&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ACE: Everything available in ACE including nanosecond timers, durations, timestamps, portable wallclock time, etc. is fully supported in MADARA. ACE is a prerequisite, so you inherit all of the portable OS time utilities from there.&lt;/p&gt;
&lt;p&gt;MADARA also provides standard get time functions&lt;/p&gt;
&lt;hr/&gt;
&lt;p&gt;&lt;strong&gt;Threads&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;The main manager of threads and time related to thread execution is the &lt;a class="" href="http://madara.sourceforge.net/docs/cpp/d8/de5/classmadara_1_1threads_1_1Threader.html"&gt;madara::threads::Threader&lt;/a&gt; class. To get predictable executions of threads that subclass from &lt;a class="" href="http://madara.sourceforge.net/docs/cpp/de/dcd/classmadara_1_1threads_1_1BaseThread.html"&gt;madara::threads::BaseThread&lt;/a&gt;, you use the &lt;code&gt;Threader::run&lt;/code&gt; with a provided hertz rate (specified as a double).&lt;/p&gt;
&lt;div class="codehilite"&gt;&lt;pre&gt;&lt;span&gt;&lt;/span&gt;&lt;span class="nt"&gt;madara&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;threads&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;Threader&lt;/span&gt; &lt;span class="nt"&gt;threader&lt;/span&gt;&lt;span class="o"&gt;;&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;run&lt;/span&gt; &lt;span class="nt"&gt;threads&lt;/span&gt; &lt;span class="nt"&gt;at&lt;/span&gt; &lt;span class="nt"&gt;50hz&lt;/span&gt; &lt;span class="nt"&gt;and&lt;/span&gt; &lt;span class="nt"&gt;1hz&lt;/span&gt;
&lt;span class="nt"&gt;threader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;run&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;10&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"analyzer"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;new&lt;/span&gt; &lt;span class="nt"&gt;AnalyzerThread&lt;/span&gt; &lt;span class="o"&gt;());&lt;/span&gt;
&lt;span class="nt"&gt;threader&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;run&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;0&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"enforcer"&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt; &lt;span class="nt"&gt;new&lt;/span&gt; &lt;span class="nt"&gt;EnforcerThread&lt;/span&gt; &lt;span class="o"&gt;());&lt;/span&gt;

&lt;span class="o"&gt;//&lt;/span&gt; &lt;span class="nt"&gt;sleep&lt;/span&gt; &lt;span class="nt"&gt;for&lt;/span&gt; &lt;span class="nt"&gt;60&lt;/span&gt; &lt;span class="nt"&gt;seconds&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;this&lt;/span&gt; &lt;span class="nt"&gt;sleep&lt;/span&gt; &lt;span class="nt"&gt;is&lt;/span&gt; &lt;span class="nt"&gt;a&lt;/span&gt; &lt;span class="nt"&gt;hard&lt;/span&gt; &lt;span class="nt"&gt;sleep&lt;/span&gt; &lt;span class="nt"&gt;that&lt;/span&gt; &lt;span class="nt"&gt;ignores&lt;/span&gt; &lt;span class="nt"&gt;interrupts&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;span class="nt"&gt;madara&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;utility&lt;/span&gt;&lt;span class="p"&gt;::&lt;/span&gt;&lt;span class="nd"&gt;sleep&lt;/span&gt; &lt;span class="o"&gt;(&lt;/span&gt;&lt;span class="nt"&gt;60&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;0&lt;/span&gt;&lt;span class="o"&gt;)&lt;/span&gt;
&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;&lt;img alt="" rel="nofollow" src="https://imgur.com/zBz8Oxp.png" title="" width="700"/&gt;&lt;/p&gt;
&lt;p&gt;The Threader enforces epochs to limit bursty behavior and control the execution of tasks. If a task runs over its epoch, it is not necessarily immediately run but instead run at the appropriate epoch as shown in the figure above.&lt;/p&gt;&lt;/div&gt;</description><dc:creator xmlns:dc="http://purl.org/dc/elements/1.1/">James Edmondson</dc:creator><pubDate>Fri, 23 Mar 2018 21:38:40 -0000</pubDate><guid>https://sourceforge.neteab20113b35522620e67ba6a030d8373978b3a10</guid></item></channel></rss>