--- /dev/null
+*.[oa]
+Makefile.in
<?xml version='1.0'?>
<doc style="main.css">
<book>
+ <titlepage>
+ <title>Tachyon</title>
+ </titlepage>
+
<chapter>
<heading>Introduction</heading>
<item tag='int nanosleep(struct timespec req)'>
Suspend execution until the time in req is passed. That time is divided by the accelleration set in the Tachyon object. So, if a waiting time of 60 seconds is requested and the accelleration is 10, execution will be actually be suspended for 6 seconds.
+The time is specified with nanosecond precision in the <code>struct timespec</code>. It is defined as follows:
+<verbatim>
+ struct timespec
+ {
+ time_t tv_sec; /* seconds */
+ long tv_nsec; /* nanoseconds */
+ };
+
+
+</verbatim>
+</item>
+
+<item tag='int nanosleep(float req)'>
+Suspend execution until the time in req is passed. That time is divided by the accelleration set in the Tachyon object. So, if a waiting time of 60 seconds is requested and the accelleration is 10, execution will be actually be suspended for 6 seconds.
+The time is specified with nanosecond precision in a floating point number.
</item>
<item tag='settime (time_t sec)'>
::nanosleep(&req, NULL);
}
+int Tachyon::nanosleep(float req)
+{
+ double seconds;
+ double nanoseconds;
+ struct timespec req_t;
+
+ seconds = req / accelleration;
+ nanoseconds = (seconds - trunc(seconds)) * 1.0e9;
+
+ req_t.tv_sec = trunc(seconds);
+ req_t.tv_nsec = trunc(nanoseconds);
+
+ ::nanosleep(&req_t, NULL);
+}
+
void Tachyon::settime(time_t sec)
{
}
time_t time(void);
int nanosleep(struct timespec req);
+ int nanosleep(float req);
void settime(time_t sec);
void accellerate(double factor);
-TESTS = create sleep accellerate
+TESTS = create sleep accellerate sleep_float accellerate_float
AM_CPPFLAGS = -I../src
LDADD = ../src/.libs/libTachyon.la -lrt -lm
-check_PROGRAMS = create sleep
+check_PROGRAMS = create sleep sleep_float
-create_SOURCES = create.cpp
-sleep_SOURCES = sleep.cpp
+create_SOURCES = create.cpp
+sleep_SOURCES = sleep.cpp
+sleep_float_SOURCES = sleep_float.cpp
clean-local:
rm -f sleep.tmp
--- /dev/null
+#!/bin/bash
+
+set -m
+
+PATH=../src:$PATH
+
+START_TIME=`date +%s`
+./sleep_float >sleep.tmp &
+sleep 1
+read a b c TACHYON_NAME <sleep.tmp
+tachyon -a 20 $TACHYON_NAME
+fg
+END_TIME=`date +%s`
+duration=$(($END_TIME - $START_TIME))
+echo "Elapsed time is $duration"
+if [[ $duration -eq 6 ]] || [[ $duration -eq 5 ]]
+then
+ echo "Elapsed time within 7 seconds"
+ exit 0
+fi
+echo "Elapsed time $duration seconds is unexpected."
+exit 1
--- /dev/null
+#include <iostream>
+#include "Tachyon.h"
+
+int main()
+{
+
+ Tachyon timebase;
+ float interval;
+
+ interval = 3.33;
+
+ std::cout << "Tachyon name is " << timebase.name() << "\n";
+ std::cout.flush();
+ for (int i = 0; i < 10; i++)
+ {
+ timebase.nanosleep(interval);
+ std::cout << "3.3 seconds.\n";
+ }
+}