|
Home About Us A-Z Index Search * Contact Us Register Login Press ShopThe Open Brand -- Problem Reporting and Interpretations System |
Problem Report 0200 Details
Show help | Quick Search | Submit a Test Suite Support Request | Click here to view your privileges
This page provides all information on Problem Report 0200.
Report 0200 Actions
Problem Report Number 0200 Submitter's Classification Test Suite problem State Resolved Resolution Test Suite Deficiency (TSD) Problem Resolution ID TSD.X.0200 Raised 1995-01-05 08:00 Updated 2003-03-13 08:00 Published 1995-01-18 08:00 Product Standard Internationalised System Calls and Libraries (XPG4) Certification Program The Open Brand certification program Test Suite VSX4 version 4.3.4 Test Identification XOPEN.os/time/clock 1 Problem Summary TSD4.200 The VSX4 test suite is using clock() in a nonportable manner. Here is a section of code from XOPEN.os/time/clock/clock.c: private void prepare_tests() { . . . (void) clock(); /* when clock is called, ... Problem Text
The VSX4 test suite is using clock() in a nonportable manner.
Here is a section of code from XOPEN.os/time/clock/clock.c:
private void
prepare_tests()
{
.
.
.
(void) clock(); /* when clock is called, the value returned is the
* CPU time used since the last call. This call
* is initialisation.
*/
.
.
.
/* waste some user time */
for (count = 0; count < COUNT_UT; count++)
{
PATH_TRACE;
use_time();
}
.
.
.
clock1 = clock();
.
.
.
The initial invocation of the function (note especially the comment)
is clearly in conflict with the XPG4 standard:
"DESCRIPTION
The {clock()} function returns the implementation's best
approximation to the processor time used by the process since the
beginning of an implementation-dependent time related only to the
process invocation."
and:
"APPLICATION USAGE
In order to measure time spent in a program, the {clock()} function
should be called at the start of the program and its return value
subtracted from the value returned by subsequent calls. ..."
In the test suite results above, we claim that the difference between
the times is a result of the clock() function being used incorrectly.
If the test is changed to calculate the value of clock1 by
subtracting the value returned by clock() prior to the loop from the
value returned after the loop, the test is successful. Here is
an example of how the code should be written:
private void
prepare_tests()
{
.
.
.
clock1 = clock(); /* obtain CPU time before loop */
.
.
.
/* waste some user time */
for (count = 0; count < COUNT_UT; count++)
{
PATH_TRACE;
use_time();
}
.
.
.
clock1 = clock() - clock1; /* calculate change in CPU time */
.
.
.Test Output
/tset/XOPEN.os/time/clock/T.clock 1 Failed
Test Description:
clock() returns the amount of CPU time (in microseconds) used since
the first call to clock().
(See PARAMETERS : VSX_CLOCK_ERR below)
Test Strategy:
CALL clock() and times(), saving CPU times given by times()
EXECUTE user and system code, using use_time() and sys_call()
VERIFY that the value returned by clock() agrees with the increase in
CPU times given by times() to within VSX_CLOCK_ERR percent
Test Information:
CPU time used as given by clock() does not correspond to value given by
times() within tolerance limits
CPU time as given by times is 50000 microseconds
CPU time as given by clock is 90998 microsecondsReview Information
Review Type TSMA Review Start Date null Completed null Status Complete Review Recommendation No Resolution Given Review Response
The test suite aligns with the statements in XPG3 rather than those
in XSH4. The CHANGE HISTORY section of XSH4 states that the changes
made in the Issue 4 update are "functionally equivalent to Issue 3".
This statement seems to be misleading since in XPG3 it states that:
"The clock() function returns the amount of CPU time used since the
first call to clock()"
and in XSH4 it states that:
"The clock() function returns .... the processor time used since the
beginning of ...... time related only to the process invocation."
The current code follows the strategy defined for XPG3 and needs to be
aligned with the XSH4 description.
A permanent waiver is recommended on the basis of a test suite deficiency.
Review Type SA Review Start Date null Completed null Status Complete Review Resolution Test Suite Deficiency (TSD) Review Conclusion
This is an agreed Test Suite Deficiency.
Problem Reporting System Options:
- View Report 0200
- List All PRs
- Search Reports
- Email the System Administrator
- View the The Open Brand Interpretations Database User Manual
Contact the Certification Authority