tv_sec is the number of seconds
tv_nsec is the number of nanoseconds
output on my desktop is:
compile and run the code. Then come back with more questions.
Hi ,
I have three funcions f1, f2 and f3 .
f1 calls f2 and f2 calls f3 .
I have a global variable "period" which i want to pass to f3 .
Can i pass the variable directly in the definition of f3 ?
Pls help .
sars (4 Replies)
Hi.
Problem: I have to parse the payload of a packet. The payload could be in Big Endian Format (network byte order) or little. That depends on a flag present in the header of the packet.
Solution: A horrible solution could be to check for that flag everytime I have to read a field in the... (11 Replies)
This is my function which is creating three variables based on counter & writing these variable to database by calling another function writeRecord
but only one record is getting wrote in DB.... Please advise ASAP...:confused:
function InsertFtg
{
FTGSTR=""
echo "Saurabh is GREAT $#"
let... (2 Replies)
I have the following code :
function1 ()
{
print "January"
}
function2()
{
case $1 in
January)
print "Dzisiaj mamy styczen"
;;
*)
;;
}
main()
{ (1 Reply)
In gdb, I can call one function with command "call", but how can I step in the function? I don't want to restart the program, but the function had been executed, gdb will execute next statement, and I don't know how to recall the function. (4 Replies)
I have a script which does gunzip, zip and untar.
Input to the script is file name and file directory (where file is located)
I am reading the input parameters as follows:
FILENAME=$1
FILEDIR=$2
I have created 3 functions that are as follows:
1) gunzip file
2) unzip file... (2 Replies)
Dear All.
I have a script, which process files one by one. In the script I have two functions.
one sftp files to different server
the other from existing file create file with different name.
My question is:
Will sftp function recognize files names , which are created in another... (1 Reply)
Hi,
I am having script which contains many functions. Need to print each function name at the starting of the function. Like below,
functionname()
{
echo "functionname"
commands....
}
I've tried like below,
func=`grep "()" scriptname | cut -d "(" -f1`
for i in $func
do
nawk -v... (4 Replies)
Hi All,
Good Day, seeking for your assistance on how to not perform my 2nd, 3rd,4th etc.. function if my 1st function is in else condition.
#Body
function1()
{
if
then
echo "exist"
else
echo "not exist"
}
#if not exist in function1 my all other function will not proceed.... (4 Replies)
Discussion started by: meister29
4 Replies
LEARN ABOUT NETBSD
timespec
TIMEVAL(3) BSD Library Functions Manual TIMEVAL(3)NAME
timeval, timespec, itimerval, itimerspec, bintime -- time structures
SYNOPSIS
#include <sys/time.h>
void
TIMEVAL_TO_TIMESPEC(struct timeval *tv, struct timespec *ts);
void
TIMESPEC_TO_TIMEVAL(struct timeval *tv, struct timespec *ts);
DESCRIPTION
The <sys/time.h> header, included by <time.h>, defines various structures related to time and timers.
1. The following structure is used by gettimeofday(2), among others:
struct timeval {
time_t tv_sec;
suseconds_t tv_usec;
};
The tv_sec member represents the elapsed time, in whole seconds. The tv_usec member captures rest of the elapsed time, represented as
the number of microseconds.
2. The following structure is used by nanosleep(2), among others:
struct timespec {
time_t tv_sec;
long tv_nsec;
};
The tv_sec member is again the elapsed time in whole seconds. The tv_nsec member represents the rest of the elapsed time in nanosec-
onds.
A microsecond is equal to one millionth of a second, 1000 nanoseconds, or 1/1000 milliseconds. To ease the conversions, the macros
TIMEVAL_TO_TIMESPEC() and TIMESPEC_TO_TIMEVAL() can be used to convert between struct timeval and struct timespec.
3. The following structure is used by setitimer(2), among others:
struct itimerval {
struct timeval it_interval;
struct timeval it_value;
};
4. The following structure is used by timer_settime(2), among others:
struct itimerspec {
struct timespec it_interval;
struct timespec it_value;
};
Both struct itimerval and struct itimerspec are used to specify when a timer expires. Generally, it_interval specifies the period
between successive timer expirations. A value zero implies that the alarm will fire only once. If it_value is non-zero, it indicates
the time left to the next timer expiration. A value zero implies that the timer is disabled.
5. The following structure is used by bintime(9), among others:
struct bintime {
time_t sec;
uint64_t frac;
};
The sec member specifies the time in seconds and frac represents a 64-bit fraction of seconds. The struct bintime is meant to be used
in the kernel only. It is further described in timecounter(9).
EXAMPLES
It can be stressed that the traditional UNIX timeval and timespec structures represent elapsed time, measured by the system clock (see
hz(9)). The following sketch implements a function suitable for use in a context where the timespec structure is required for a conditional
timeout:
static void
example(struct timespec *spec, time_t minutes)
{
struct timeval elapsed;
(void)gettimeofday(&elapsed, NULL);
_DIAGASSERT(spec != NULL);
TIMEVAL_TO_TIMESPEC(&elapsed, spec);
/* Add the offset for timeout in minutes. */
spec->tv_sec = spec->tv_sec + minutes * 60;
}
A better alternative would use the more precise clock_gettime(2).
SEE ALSO timeradd(3), tm(3), bintime_add(9)BSD April 12, 2011 BSD