open_posix_testsuite: Don't use clock_settime() to reset a CPU-time Clock
PATCH 1/1 open_posix_testsuite: Don't use clock_settime() to reset a CPU-time Clock
This case is trying to set CPU-time clock(ID is returned by clock_getcpuclockid()) of a specific process by calling clock_settime(). But Linux kernel doesn't allow to reset a CPU-time clock of a specific process. Kernel returns -EPERM. So test fails.
In "IEEE Std 1003.1, 2004 Edition", It's said as following:
If _POSIX_CPUTIME is defined, implementations shall support clock ID values obtained by invoking clock_getcpuclockid(), which represent the CPU-time clock of a given process. Implementations shall also support the special clockid_t value CLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions. For these clock IDs, the values returned by clock_gettime() and specified by clock_settime() represent the amount of execution time of the process associated with the clock. Changing the value of a CPU-time clock via clock_settime() shall have no effect on the behavior of the sporadic server scheduling policy.
So the behaviour when changing the value of a CPU-time clock via clock_settime() is operating system specific.
We may change the test progress to stop using clock_settime(). Now, We just make use of clock_gettime() instead to achieve the same test purpose.
--- .../interfaces/clock_getcpuclockid/2-1.c | 67 ++++++++++---------- 1 files changed, 33 insertions(+), 34 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/2-1.c +33 -34
@@ -23,48 +23,47 @@ int main(int argc, char *argv[])printf ("_POSIX_CPUTIME unsupported\n" );return PTS_UNSUPPORTED ;#else -unsigned long time_to_set;clockid_t clockid_1, clockid_2;struct timespec tp1, tp2; +int i;if (sysconf (_SC_CPUTIME) ==-1 ) {printf ("_POSIX_CPUTIME unsupported\n" );return PTS_UNSUPPORTED ; } -if (clock_getcpuclockid (getpid (), &clockid_1) !=0 ) { -printf ("clock_getcpuclockid(getpid(), ) failed\n" ); -return PTS_FAIL ; - } - -if (clock_getcpuclockid (0 , &clockid_2) !=0 ) { -printf ("clock_getcpuclockid(0, ) failed\n" ); -return PTS_FAIL ; - } +for (i =0 ; i <10 ; i++) { +if (clock_getcpuclockid (getpid (), &clockid_1) !=0 ) { +printf ("clock_getcpuclockid(getpid(), ) failed\n" ); +return PTS_FAIL ; + } -/* Set clockid_1 as a random value from 1 sec to 10 sec */ -srand ((unsigned long )time (NULL )); - time_to_set =rand () *10.0 /RAND_MAX +1 ; - tp1.tv_sec = time_to_set; - tp1.tv_nsec =0 ; -if (clock_settime (clockid_1, &tp1) !=0 ) { -printf ("clock_getcpuclockid() returned an invalid clockid_t: " -"%d\n" , clockid_1); -return PTS_FAIL ; - } -/* Get the time of clockid_2, should almost the same as clockid_1 */ -if (clock_gettime (clockid_2, &tp2) !=0 ) { -printf ("clock_getcpuclockid() returned an invalid clockid_t: " -"%d\n" , clockid_2); -return PTS_FAIL ; - } -if (tp1.tv_sec == tp2.tv_sec) - { -printf ("Test PASSED\n" ); -return PTS_PASS ; - } -printf ("Test FAILED\n" ); -return PTS_FAIL ; - +if (clock_getcpuclockid (0 , &clockid_2) !=0 ) { +printf ("clock_getcpuclockid(0, ) failed\n" ); +return PTS_FAIL ; + } + +/* Get the time of clockid_1 */ +if (clock_gettime (clockid_1, &tp1) !=0 ) { +printf ("clock_getcpuclockid() returned an invalid clockid_t: " +"%d\n" , clockid_1); +return PTS_FAIL ; + } + +/* Get the time of clockid_2, should almost the same as clockid_1 */ +if (clock_gettime (clockid_2, &tp2) !=0 ) { +printf ("clock_getcpuclockid() returned an invalid clockid_t: " +"%d\n" , clockid_2); +return PTS_FAIL ; + } + +if (tp1.tv_sec != tp2.tv_sec) { +printf ("Test FAILED\n" ); +return PTS_FAIL ; + } + } + +printf ("Test PASSED\n" ); +return PTS_PASS ;#endif }
Signature · 14 lines
1.7.0.4 ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 15 lines · Gui Jianfeng
This case is trying to set CPU-time
clock(ID is returned by clock_getcpuclockid())of a specific process by callingclock_settime(). But Linux kernel doesn't allow to reset a CPU-time clock of a specific process. Kernel returns-EPERM. So test fails.In "IEEE Std 1003.1, 2004 Edition", It's said as following:
If_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock. Changing the value of a CPU-time clock viaclock_settime()shall have no effect on the behavior of the sporadic server scheduling policy.
Quoted 7 lines
So the behaviour when changing the value of a CPU-time clock via
clock_settime()is operating system specific.We may change the test progress to stop using
clock_settime(). Now, We just make use ofclock_gettime()instead to achieve the same test purpose.Signed-off-by Gui Jianfeng <[email protected]>
Hi Garrett,
How do you think this fix?
Gui
Quoted 80 lines
--- .../interfaces/clock_getcpuclockid/2-1.c | 67 ++++++++++---------- 1 files changed, 33 insertions(+), 34 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/2-1.c +25
-34@@ -23,48 +23,47 @@ int main(int argc, char *argv[])printf ("_POSIX_CPUTIME unsupported\n" );return PTS_UNSUPPORTED ;#else -unsigned long time_to_set;clockid_t clockid_1, clockid_2;struct timespec tp1, tp2; +int i;if (sysconf (_SC_CPUTIME) ==-1 ) {printf ("_POSIX_CPUTIME unsupported\n" );return PTS_UNSUPPORTED ; } -if (clock_getcpuclockid (getpid (), &clockid_1) !=0 ) { -printf ("clock_getcpuclockid(getpid(), ) failed\n" ); -return PTS_FAIL ; - } - -if (clock_getcpuclockid (0 , &clockid_2) !=0 ) { -printf ("clock_getcpuclockid(0, ) failed\n" ); -return PTS_FAIL ; - } +for (i =0 ; i <10 ; i++) { +if (clock_getcpuclockid (getpid (), &clockid_1) !=0 ) { +printf ("clock_getcpuclockid(getpid(), ) failed\n" ); +return PTS_FAIL ; + } -/* Set clockid_1 as a random value from 1 sec to 10 sec */ -srand ((unsigned long )time (NULL )); - time_to_set =rand () *10.0 /RAND_MAX +1 ; - tp1.tv_sec = time_to_set; - tp1.tv_nsec =0 ; -if (clock_settime (clockid_1, &tp1) !=0 ) { -printf ("clock_getcpuclockid() returned an invalid clockid_t: " -"%d\n" , clockid_1); -return PTS_FAIL ; - } -/* Get the time of clockid_2, should almost the same as clockid_1 */ -if (clock_gettime (clockid_2, &tp2) !=0 ) { -printf ("clock_getcpuclockid() returned an invalid clockid_t: " -"%d\n" , clockid_2); -return PTS_FAIL ; - } -if (tp1.tv_sec == tp2.tv_sec) - { -printf ("Test PASSED\n" ); -return PTS_PASS ; - } -printf ("Test FAILED\n" ); -return PTS_FAIL ; - +if (clock_getcpuclockid (0 , &clockid_2) !=0 ) { +printf ("clock_getcpuclockid(0, ) failed\n" ); +return PTS_FAIL ; + } + +/* Get the time of clockid_1 */ +if (clock_gettime (clockid_1, &tp1) !=0 ) { +printf ("clock_getcpuclockid() returned an invalid clockid_t: " +"%d\n" , clockid_1); +return PTS_FAIL ; + } + +/* Get the time of clockid_2, should almost the same as clockid_1 */ +if (clock_gettime (clockid_2, &tp2) !=0 ) { +printf ("clock_getcpuclockid() returned an invalid clockid_t: " +"%d\n" , clockid_2); +return PTS_FAIL ; + } +
testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/2-1.c int main(int argc, char *argv[]) · line 69
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/2-1.c +8
-0+if (tp1.tv_sec != tp2.tv_sec) { +printf ("Test FAILED\n" ); +return PTS_FAIL ; + } + } + +printf ("Test PASSED\n" ); +return PTS_PASS ;#endif }
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 19 lines · Gui Jianfeng
Quoted 18 lines · Gui Jianfeng
This case is trying to set CPU-time
clock(ID is returned by clock_getcpuclockid())of a specific process by callingclock_settime(). But Linux kernel doesn't allow to reset a CPU-time clock of a specific process. Kernel returns-EPERM. So test fails.In "IEEE Std 1003.1, 2004 Edition", It's said as following:
If_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock. Changing the value of a CPU-time clock viaclock_settime()shall have no effect on the behavior of the sporadic server scheduling policy.So the behaviour when changing the value of a CPU-time clock via
clock_settime()is operating system specific.
Quoted 8 lines
Quoted 4 lines
We may change the test progress to stop using
clock_settime(). Now, We just make use ofclock_gettime()instead to achieve the same test purpose.Signed-off-by Gui Jianfeng <[email protected]>Hi Garrett,
How do you think this fix?
The tort is the same in POSIX 2008.1. Taking out the chaff...
a. If _POSIX_CPUTIME is defined, implementations shall support clock ID values obtained by invoking clock_getcpuclockid(), which represent the CPU-time clock of a given process.
b. Implementations shall also support the special clockid_t value CLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions.
c. For these clock IDs, the values returned by clock_gettime() and specified by clock_settime() represent the amount of execution time of the process associated with the clock.
Nowhere does it say that you can't set that clock. Try running the test as root to see what you can do... if the test fails (even as root), then Linux needs to be fixed to conform to POSIX.
Also, try running the other tests I just added to see whether or not the function call fails per POSIX's requirements.
Thanks!
-Garrett
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 41 lines · Garrett Cooper
Quoted 19 lines · Gui Jianfeng
Quoted 18 lines · Gui Jianfeng
This case is trying to set CPU-time
clock(ID is returned by clock_getcpuclockid())of a specific process by callingclock_settime(). But Linux kernel doesn't allow to reset a CPU-time clock of a specific process. Kernel returns-EPERM. So test fails.In "IEEE Std 1003.1, 2004 Edition", It's said as following:
If_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock. Changing the value of a CPU-time clock viaclock_settime()shall have no effect on the behavior of the sporadic server scheduling policy.So the behaviour when changing the value of a CPU-time clock via
clock_settime()is operating system specific.Quoted 7 lines
Quoted 4 lines
We may change the test progress to stop using
clock_settime(). Now, We just make use ofclock_gettime()instead to achieve the same test purpose.Signed-off-by Gui Jianfeng <[email protected]>Hi Garrett,
How do you think this fix?
The tort is the same in POSIX 2008.1. Taking out the chaff...
a. If
_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process.
b. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions.
c. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock.
Quoted 3 lines
Nowhere does it say that you can't set that clock. Try running the test as root to see what you can do... if the test fails (even as root), then Linux needs to be fixed to conform to POSIX.
POSIX also says that:
Changing the value of a CPU-time clock via clock_settime() shall have no effect on the behavior of the sporadic server scheduling policy.
IMHO, this means clock_settime() implementation is OS specific, is it? So, even if Linux fails to set this clock, it's just fine. Am i missing something?
Gui
Quoted 7 lines
Also, try running the other tests I just added to see whether or not the function call fails per POSIX's requirements.
Thanks!
-Garrett
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 45 lines · Gui Jianfeng
Quoted 40 lines · Garrett Cooper
Quoted 19 lines · Gui Jianfeng
Quoted 18 lines · Gui Jianfeng
This case is trying to set CPU-time
clock(ID is returned by clock_getcpuclockid())of a specific process by callingclock_settime(). But Linux kernel doesn't allow to reset a CPU-time clock of a specific process. Kernel returns-EPERM. So test fails.In "IEEE Std 1003.1, 2004 Edition", It's said as following:
If_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock. Changing the value of a CPU-time clock viaclock_settime()shall have no effect on the behavior of the sporadic server scheduling policy.So the behaviour when changing the value of a CPU-time clock via
clock_settime()is operating system specific.Quoted 7 lines
Quoted 4 lines
We may change the test progress to stop using
clock_settime(). Now, We just make use ofclock_gettime()instead to achieve the same test purpose.Signed-off-by Gui Jianfeng <[email protected]>Hi Garrett,
How do you think this fix?
The tort is the same in POSIX 2008.1. Taking out the chaff...
a. If
_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process.
b. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions.
c. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock.Quoted 3 lines
Nowhere does it say that you can't set that clock. Try running the test as root to see what you can do... if the test fails (even as root), then Linux needs to be fixed to conform to POSIX.
Quoted 6 lines
POSIX also says that:
Changing the value of a CPU-time clock viaclock_settime()shall have no effect on the behavior of the sporadic server scheduling policy.IMHO, this means
clock_settime()implementation is OS specific, is it? So, even if Linux fails to set this clock, it's just fine. Am i missing something?
Hi Garrett,
If you don't object, would you apply this patch?
Gui
Quoted 10 lines
Gui
Quoted 6 lines
Also, try running the other tests I just added to see whether or not the function call fails per POSIX's requirements.
Thanks!
-Garrett
Quoted 11 lines
------------------------------------------------------------------------------
The Next 800 Companies to Lead America's Growth: New Video Whitepaper David G. Thomson, author of the best-selling book "Blueprint to a Billion" shares his insights and actions to help propel your business during the next growth cycle. Listen Now!
http://p.sf.net/sfu/SAP-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Centralized Desktop Delivery: Dell and VMware Reference Architecture Simplifying enterprise desktop deployment and management using Dell EqualLogic storage and VMware View: A highly scalable, end-to-end client virtualization framework. Read more!
http://p.sf.net/sfu/dell-eql-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 13 lines
The tort is the same in POSIX 2008.1. Taking out the chaff...
a. If
_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process.
b. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions.
c. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock.
Quoted 7 lines
Nowhere does it say that you can't set that clock. Try running the test as root to see what you can do... if the test fails (even as root), then Linux needs to be fixed to conform to POSIX.
Also, try running the other tests I just added to see whether or not the function call fails per POSIX's requirements.
From clock_settime POSIX documentation:
...
The effect of setting a clock via clock_settime() on armed per-process timers associated with that clock is implementation-dependent.
The appropriate privilege to set a particular clock is implementation-dependent.
...
From man clock_settime:
...
According to POSIX.1-2001, a process with "appropriate privileges" may set the CLOCK_PROCESS_CPUTIME_ID and CLOCK_THREAD_CPUTIME_ID clocks using clock_settime(). On Linux, these clocks are not settable (i.e., no process has "appropriate privileges").
...
This is pretty creative understanding of the standart, but I couldn't say it's wrong anyway.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today http://p.sf.net/sfu/msIE9-sfdev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi!
Quoted 72 lines
Quoted 51 lines
Quoted 51 lines
Quoted 41 lines
Quoted 13 lines
The tort is the same in POSIX 2008.1. Taking out the chaff...
a. If
_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process.
b. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions.
c. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock.Quoted 7 lines
Nowhere does it say that you can't set that clock. Try running the test as root to see what you can do... if the test fails (even as root), then Linux needs to be fixed to conform to POSIX.
Also, try running the other tests I just added to see whether or not the function call fails per POSIX's requirements.
From
clock_settimePOSIX documentation:...
The effect of setting a clock via
clock_settime()on armed per-process timers associated with that clock is implementation-dependent.The appropriate privilege to set a particular clock is implementation-dependent.
...
From man
clock_settime:...
According to POSIX.1-2001, a process with "appropriate privileges" may set the
CLOCK_PROCESS_CPUTIME_IDandCLOCK_THREAD_CPUTIME_IDclocks usingclock_settime(). On Linux, these clocks are not settable (i.e., no process has "appropriate privileges").Quoted 6 lines
...
This is pretty creative understanding of the standart, but I couldn't say it's wrong anyway.
I agree that privilege is multitiered and the implications of running as a particular user, whether or not SELinux is enabled, MAC allows it, etc are all bits to take into consideration.
Quoted 8 lines
Quoted 2 lines
Just running the program as root seems like a simple test to run to see whether or not the testcase passes.
FYI, I removed the
clock_settimecall and simplified the testcase
because it wasn't really buying much in the overall scheme of things to make sure that the time matched on the two clock values. If anything that should be tested with theclock_settimeconformance testcase.Hi Cooper,
I have a look of the code you modified. Consider the following piece:
/* Get the time of clockid_1. */ if (clockid_1 != clockid_2) { printf("clock_getcpuclockid(0, ..) != " "clock_getcpuclockid(%d, ..): (%d != %d)\n", clockid_1, clockid_2); return PTS_FAIL; }
Quoted 3 lines
IMO, you can't do such comparision, it's problematic. In this case,
clockid_1andclockid_2own different values, but they point to the same clock. So you can't modify like this.
Yes this assumption seems to be incorrect as I couldn't find in a place in POSIX documentation which explicitly states that two obtained clock_id that points to the same clock must be the same. On linux calling clock_getcpuclockid() with 0 and value from getpid() returns two different id which both points to the same clock.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Increase Visibility of Your 3D Game App & Earn a Chance To Win $500! Tap into the largest installed PC base & get more eyes on your game by optimizing for Intel(R) Graphics Technology. Get started today with the Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs. http://p.sf.net/sfu/intelisp-dev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
Quoted 5 lines
Yes this assumption seems to be incorrect as I couldn't find in a place in POSIX documentation which explicitly states that two obtained
clock_idthat points to the same clock must be the same. On linux callingclock_getcpuclockid()with 0 and value fromgetpid()returns two different id which both points to the same clock.
Garrett ping.
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi Garrett,
This case always fails when I do the test. Would you take a look this patch, If you don't object, can you commit this patch? Or give some comments about it.
Thanks,
Gui
Quoted 102 lines · Gui Jianfeng
This case is trying to set CPU-time
clock(ID is returned by clock_getcpuclockid())of a specific process by callingclock_settime(). But Linux kernel doesn't allow to reset a CPU-time clock of a specific process. Kernel returns-EPERM. So test fails.In "IEEE Std 1003.1, 2004 Edition", It's said as following:
If_POSIX_CPUTIMEis defined, implementations shall support clock ID values obtained by invokingclock_getcpuclockid(), which represent the CPU-time clock of a given process. Implementations shall also support the specialclockid_tvalueCLOCK_PROCESS_CPUTIME_ID, which represents the CPU-time clock of the calling process when invoking one of the clock_*() or timer_*() functions. For these clock IDs, the values returned byclock_gettime()and specified byclock_settime()represent the amount of execution time of the process associated with the clock. Changing the value of a CPU-time clock viaclock_settime()shall have no effect on the behavior of the sporadic server scheduling policy.So the behaviour when changing the value of a CPU-time clock via
clock_settime()is operating system specific.We may change the test progress to stop using
clock_settime(). Now, We just make use ofclock_gettime()instead to achieve the same test purpose.Signed-off-by Gui Jianfeng <[email protected]>--- .../interfaces/clock_getcpuclockid/2-1.c | 67 ++++++++++---------- 1 files changed, 33 insertions(+), 34 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/2-1.c +25
-34@@ -23,48 +23,47 @@ int main(int argc, char *argv[])printf ("_POSIX_CPUTIME unsupported\n" );return PTS_UNSUPPORTED ;#else -unsigned long time_to_set;clockid_t clockid_1, clockid_2;struct timespec tp1, tp2; +int i;if (sysconf (_SC_CPUTIME) ==-1 ) {printf ("_POSIX_CPUTIME unsupported\n" );return PTS_UNSUPPORTED ; } -if (clock_getcpuclockid (getpid (), &clockid_1) !=0 ) { -printf ("clock_getcpuclockid(getpid(), ) failed\n" ); -return PTS_FAIL ; - } - -if (clock_getcpuclockid (0 , &clockid_2) !=0 ) { -printf ("clock_getcpuclockid(0, ) failed\n" ); -return PTS_FAIL ; - } +for (i =0 ; i <10 ; i++) { +if (clock_getcpuclockid (getpid (), &clockid_1) !=0 ) { +printf ("clock_getcpuclockid(getpid(), ) failed\n" ); +return PTS_FAIL ; + } -/* Set clockid_1 as a random value from 1 sec to 10 sec */ -srand ((unsigned long )time (NULL )); - time_to_set =rand () *10.0 /RAND_MAX +1 ; - tp1.tv_sec = time_to_set; - tp1.tv_nsec =0 ; -if (clock_settime (clockid_1, &tp1) !=0 ) { -printf ("clock_getcpuclockid() returned an invalid clockid_t: " -"%d\n" , clockid_1); -return PTS_FAIL ; - } -/* Get the time of clockid_2, should almost the same as clockid_1 */ -if (clock_gettime (clockid_2, &tp2) !=0 ) { -printf ("clock_getcpuclockid() returned an invalid clockid_t: " -"%d\n" , clockid_2); -return PTS_FAIL ; - } -if (tp1.tv_sec == tp2.tv_sec) - { -printf ("Test PASSED\n" ); -return PTS_PASS ; - } -printf ("Test FAILED\n" ); -return PTS_FAIL ; - +if (clock_getcpuclockid (0 , &clockid_2) !=0 ) { +printf ("clock_getcpuclockid(0, ) failed\n" ); +return PTS_FAIL ; + } + +/* Get the time of clockid_1 */ +if (clock_gettime (clockid_1, &tp1) !=0 ) { +printf ("clock_getcpuclockid() returned an invalid clockid_t: " +"%d\n" , clockid_1); +return PTS_FAIL ; + } + +/* Get the time of clockid_2, should almost the same as clockid_1 */ +if (clock_gettime (clockid_2, &tp2) !=0 ) { +printf ("clock_getcpuclockid() returned an invalid clockid_t: " +"%d\n" , clockid_2); +return PTS_FAIL ; + } +
testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/2-1.c int main(int argc, char *argv[]) · line 69
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/clock_getcpuclockid/2-1.c +8
-0+if (tp1.tv_sec != tp2.tv_sec) { +printf ("Test FAILED\n" ); +return PTS_FAIL ; + } + } + +printf ("Test PASSED\n" ); +return PTS_PASS ;#endif }
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Hi!
I've just commited a slightly different fix which:
* reports sucess if clock ids are the same
* check differencies of timers, if they arent
Garrett, could you check this version works on BSD as well?
Signature · 13 lines
Cyril Hrubis [email protected] ------------------------------------------------------------------------------ Free Software Download: Index, Search & Analyze Logs and other IT data in Real-Time with Splunk. Collect, index and harness all the fast moving IT data generated by your applications, servers and devices whether physical, virtual or in the cloud. Deliver compliance at lower cost and gain new business insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list