× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



So, there is a 10 ms overhead roughly on iOS but under load I guess that will vary.

To: c400-l@xxxxxxxxxxxx
From: kc2hiz@xxxxxxxxx
Date: Wed, 16 Apr 2014 10:00:40 -0400
Subject: Re: [C400-L] waittime function precision

On 4/16/2014 3:39 AM, Jevgeni Astanovski wrote:
I tried what you said (_WAIT_MPL_SET)
Results are pretty similar:
Delay = 10 ms, waittime: 18.480 ms
Delay = 20 ms, waittime: 38.960 ms
Delay = 30 ms, waittime: 59.432 ms
Delay = 40 ms, waittime: 52.360 ms
Delay = 50 ms, waittime: 69.720 ms
Delay = 60 ms, waittime: 89.440 ms
Delay = 70 ms, waittime: 69.824 ms
Delay = 80 ms, waittime: 91.824 ms
Delay = 90 ms, waittime: 119.128 ms

Actually I do not expect that waittime is somewhat precise in milliseconds range - at least I see it isn't.
If you tell her to wait for a minute, you probably do not care about +/- 20ms!

But is there something that works reasonably in a milliseconds range?

I normally think of usleep() but that is not precise on IBM i either.
Here are some runs I did:

Delay = 10 ms, waittime: 20.024 ms
Delay = 20 ms, waittime: 40.016 ms
Delay = 30 ms, waittime: 60.024 ms
Delay = 40 ms, waittime: 70.024 ms
Delay = 50 ms, waittime: 71.920 ms
Delay = 60 ms, waittime: 74.640 ms
Delay = 70 ms, waittime: 100.024 ms
Delay = 80 ms, waittime: 110.024 ms
Delay = 90 ms, waittime: 120.024 ms

Delay = 10 ms, waittime: 10.072 ms
Delay = 20 ms, waittime: 40.024 ms
Delay = 30 ms, waittime: 38.376 ms
Delay = 40 ms, waittime: 41.104 ms
Delay = 50 ms, waittime: 80.024 ms
Delay = 60 ms, waittime: 66.120 ms
Delay = 70 ms, waittime: 72.312 ms
Delay = 80 ms, waittime: 110.024 ms
Delay = 90 ms, waittime: 120.032 ms

Delay = 10 ms, waittime: 12.648 ms
Delay = 20 ms, waittime: 40.024 ms
Delay = 30 ms, waittime: 31.712 ms
Delay = 40 ms, waittime: 70.024 ms
Delay = 50 ms, waittime: 57.080 ms
Delay = 60 ms, waittime: 77.936 ms
Delay = 70 ms, waittime: 74.416 ms
Delay = 80 ms, waittime: 109.944 ms
Delay = 90 ms, waittime: 120.016 ms

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

int main (int argc, char *argv[])
{
struct timeval tp1, tp2 ;
struct timezone tpz ;
decimal (9,3) Duration ;
decimal (19,6) StartTime, EndTime ;
int i ;

useconds_t useconds ;

for (i = 1; i < 10; i++)
{
gettimeofday(&tp1, &tpz) ;
StartTime = tp1.tv_usec ;
StartTime = tp1.tv_sec + (StartTime / 1000000D) ;

useconds = i * 10000 ; /* 10ms = 10 000us */
usleep(useconds) ;

gettimeofday(&tp2, &tpz) ;
EndTime = tp2.tv_usec ;
EndTime = tp2.tv_sec + (EndTime / 1000000D) ;
Duration = (decimal (9,3)) ((EndTime - StartTime) * 1000D) ;
printf("Delay = %d ms, waittime: %D(9,3) ms\n", i * 10, Duration) ;
}
return(0);
}

I tried it on Cygwin running on Windows 7. Cygwin doesn't have decimal
so I had to make some changes:

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

int main (int argc, char *argv[])
{
struct timeval tp1, tp2 ;
struct timezone tpz ;
int Duration ;
int StartTime, EndTime ;
int i ;

useconds_t useconds ;

for (i = 1; i < 10; i++)
{
gettimeofday(&tp1, &tpz) ;
StartTime = tp1.tv_usec ;

useconds = i * 10000 ; /* 10ms = 10 000us */
usleep(useconds) ;

gettimeofday(&tp2, &tpz) ;
EndTime = tp2.tv_usec ;
Duration = EndTime - StartTime ;
printf("Delay = %d ms, waittime: %d us\n", i * 10, Duration) ;
}
return(0);
}

$ ./usleep
Delay = 10 ms, waittime: 11001 us
Delay = 20 ms, waittime: 20001 us
Delay = 30 ms, waittime: 30002 us
Delay = 40 ms, waittime: 40002 us
Delay = 50 ms, waittime: 50003 us
Delay = 60 ms, waittime: 60003 us
Delay = 70 ms, waittime: 70004 us
Delay = 80 ms, waittime: 80005 us
Delay = 90 ms, waittime: 96006 us

$ ./usleep
Delay = 10 ms, waittime: 15001 us
Delay = 20 ms, waittime: 22001 us
Delay = 30 ms, waittime: 30002 us
Delay = 40 ms, waittime: 40002 us
Delay = 50 ms, waittime: 50003 us
Delay = 60 ms, waittime: 60004 us
Delay = 70 ms, waittime: 70004 us
Delay = 80 ms, waittime: 80004 us
Delay = 90 ms, waittime: 90005 us


I guess that we can't expect an operating system that is optimised for
database operations to honour precise timings in the same way that an
embedded processor or even Windows will. :-(

--buck
--
This is the Bare Metal Programming IBM i (AS/400 and iSeries) (C400-L) mailing list
To post a message email: C400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/c400-l
or email: C400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/c400-l.


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.