public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [POSIX][PATCH] sem_wait: Setting a range for time checking.
@ 2011-03-16  8:36 tangchen
  2011-03-23 16:36 ` Cyril Hrubis
  0 siblings, 1 reply; 3+ messages in thread
From: tangchen @ 2011-03-16  8:36 UTC (permalink / raw)
  To: yanegomi; +Cc: ltp-list

Hi,

According to POSIX, many historical implementations (including Version 7 
and System V) allow an alarm to occur up to a second early. Other 
implementations allow alarms up to half a second or one clock tick early 
or do not allow them to occur early at all. That means, the SIGALRM sent 
by alarm() could arrive a little earlier. So, even if sem_wait() is 
blocked, test could still fail.
Setting a range for time checking would be better. When sem_wait() is 
block and then be interrupted by SIGALRM, if the time is in this range, 
test is passed.

Signed-off-by: tangchen <tangchen@cn.fujitsu.com>
---
  .../conformance/interfaces/sem_wait/13-1.c         |    6 ++++--
  1 files changed, 4 insertions(+), 2 deletions(-)

diff --git 
a/testcases/open_posix_testsuite/conformance/interfaces/sem_wait/13-1.c 
b/testcases/open_posix_testsuite/conformance/interfaces/sem_wait/13-1.c
index 7bf547c..f30bba5 100644
--- a/testcases/open_posix_testsuite/conformance/interfaces/sem_wait/13-1.c
+++ b/testcases/open_posix_testsuite/conformance/interfaces/sem_wait/13-1.c
@@ -83,6 +83,8 @@
  /******************************************************************************/
  /***************************    Test case   
***********************************/
  /******************************************************************************/
+#define RANGE 1000000    /* 1000000 nsec */
+
  sem_t sem;

  void handler(int sig)
@@ -163,7 +165,7 @@ int main(int argc, char * argv[])
      }

      if (((ts_fin.tv_sec - ts_ref.tv_sec) * 1000000000) +
-        (ts_fin.tv_nsec - ts_ref.tv_nsec) < 1000000000)
+        (ts_fin.tv_nsec - ts_ref.tv_nsec) < (1000000000 - RANGE))
      {
          output("Ts: %d.%9.9d  ->  %d.%9.9d\n", ts_ref.tv_sec, 
ts_ref.tv_nsec, ts_fin.tv_sec, ts_fin.tv_nsec);
          FAILED("The sem_wait call did not block");
@@ -185,4 +187,4 @@ int main(int argc, char * argv[])
  #endif

      PASSED;
-}
\ No newline at end of file
+}
-- 
1.7.1

-- 
Best Regards,
Tang chen
--------------------------------------------------



------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [LTP] [POSIX][PATCH] sem_wait: Setting a range for time checking.
  2011-03-16  8:36 [LTP] [POSIX][PATCH] sem_wait: Setting a range for time checking tangchen
@ 2011-03-23 16:36 ` Cyril Hrubis
       [not found]   ` <4D8AA64A.30506@cn.fujitsu.com>
  0 siblings, 1 reply; 3+ messages in thread
From: Cyril Hrubis @ 2011-03-23 16:36 UTC (permalink / raw)
  To: tangchen; +Cc: ltp-list

Hi!
> According to POSIX, many historical implementations (including Version 7 
> and System V) allow an alarm to occur up to a second early. Other 
> implementations allow alarms up to half a second or one clock tick early 
> or do not allow them to occur early at all. That means, the SIGALRM sent 
> by alarm() could arrive a little earlier. So, even if sem_wait() is 
> blocked, test could still fail.
> Setting a range for time checking would be better. When sem_wait() is 
> block and then be interrupted by SIGALRM, if the time is in this range, 
> test is passed.

Out of curiosity, what system is this? The signal seems to arrives after
more than 1 second on all linux boxes that I have.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Enable your software for Intel(R) Active Management Technology to meet the
growing manageability and security demands of your customers. Businesses
are taking advantage of Intel(R) vPro (TM) technology - will your software 
be a part of the solution? Download the Intel(R) Manageability Checker 
today! http://p.sf.net/sfu/intel-dev2devmar
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [LTP] [POSIX][PATCH] sem_wait: Setting a range for time checking.
       [not found]   ` <4D8AA64A.30506@cn.fujitsu.com>
@ 2011-03-31 16:09     ` Cyril Hrubis
  0 siblings, 0 replies; 3+ messages in thread
From: Cyril Hrubis @ 2011-03-31 16:09 UTC (permalink / raw)
  To: tangchen; +Cc: ltp-list

Hi!
> >>According to POSIX, many historical implementations (including Version 7
> >>and System V) allow an alarm to occur up to a second early. Other
> >>implementations allow alarms up to half a second or one clock tick early
> >>or do not allow them to occur early at all. That means, the SIGALRM sent
> >>by alarm() could arrive a little earlier. So, even if sem_wait() is
> >>blocked, test could still fail.
> >>Setting a range for time checking would be better. When sem_wait() is
> >>block and then be interrupted by SIGALRM, if the time is in this range,
> >>test is passed.
> >Out of curiosity, what system is this? The signal seems to arrives after
> >more than 1 second on all linux boxes that I have.
> My box is like the following:
> 
> OS: RHEL5.5 x86-64.
> Memory: 2GB
> CPU: Intel(R) Xeon(TM) CPU 3.00GHz (4 CPUs)
> 
> 
> Sometimes it worked normally, but sometimes I got the following messages:
> 
>   Ts: 1300437153.432960442  ->  1300437154.432457949
>   Test ../../../conformance/interfaces/sem_wait/13-1.c
>   FAILED: The sem_wait call did not block

Okay, I've did a little different fix. Now the alarm is set to wait for
two seconds and we expects it to last at least one.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-03-31 15:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-16  8:36 [LTP] [POSIX][PATCH] sem_wait: Setting a range for time checking tangchen
2011-03-23 16:36 ` Cyril Hrubis
     [not found]   ` <4D8AA64A.30506@cn.fujitsu.com>
2011-03-31 16:09     ` Cyril Hrubis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox