According to my test, if the cpu numbers is less than 4, for example has 2 cpus. Then in the test case, if thread_tl() calls sched_setaffinity() to set the cpu mask, the thread_tl() may always be migrated to another cpu, it makes the thread_tl() has no chance to run agin because the TB1 or TB2 will return FAIL soon.
And if we just have only one cpu, it no need to set the cpu mask. This patch can fix the test FAIL of pidtest_2 and pidtest_3 on which has less than 4 cpus. Signed-off-by: Wanlong Gao <[email protected]> --- .../functional/threads/pi_test/pitest-2.c | 16 +++++++++------- .../functional/threads/pi_test/pitest-3.c | 14 ++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c index 244fd65..69d23f1 100644 --- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c +++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-2.c @@ -138,18 +138,20 @@ void *thread_tl(void *param) int rc; #if __linux__ - rc = sched_setaffinity((pid_t)0, sizeof(mask), &mask); + if (cpus >= 4) { + rc = sched_setaffinity((pid_t)0, sizeof(mask), &mask); + if (rc < 0) { + EPRINTF("UNRESOLVED: Thread %s index %d: Can't set affinity: %d %s", + tp->name, tp->index, rc, strerror(rc)); + exit(UNRESOLVED); + } + } #endif test_set_priority(pthread_self(),SCHED_FIFO, tp->priority); DPRINTF(stdout, "#EVENT %f Thread TL Started\n", seconds_read() - base_time); DPRINTF(stderr,"Thread %s index %d: started\n", tp->name, tp->index); - if (rc < 0) { - EPRINTF("UNRESOLVED: Thread %s index %d: Can't set affinity: %d %s", - tp->name, tp->index, rc, strerror(rc)); - exit(UNRESOLVED); - } tp->progress = 0; pthread_mutex_lock(&mutex); while (!tp->stop) @@ -360,4 +362,4 @@ int main(int argc, char **argv) ts_stop = 1; DPRINTF(stderr,"Main Thread: stop sampler thread \n"); return 0; -} \ No newline at end of file +} diff --git a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c index 20470f0..524139f 100644 --- a/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c +++ b/testcases/open_posix_testsuite/functional/threads/pi_test/pitest-3.c @@ -144,11 +144,13 @@ void *thread_tl(void *param) int rc; #if __linux__ - rc = sched_setaffinity((pid_t)0, sizeof(mask), &mask); - if (rc < 0) { - EPRINTF("UNRESOLVED: Thread %s index %d: Can't set affinity: %d %s", - tp->name, tp->index, rc, strerror(rc)); - exit(UNRESOLVED); + if (cpus >= 4) { + rc = sched_setaffinity((pid_t)0, sizeof(mask), &mask); + if (rc < 0) { + EPRINTF("UNRESOLVED: Thread %s index %d: Can't set affinity: %d %s", + tp->name, tp->index, rc, strerror(rc)); + exit(UNRESOLVED); + } } #endif @@ -376,4 +378,4 @@ int main(int argc, char **argv) ts_stop = 1; DPRINTF(stderr,"Main Thread: stop sampler thread\n"); return 0; -} \ No newline at end of file +} -- 1.7.6 ------------------------------------------------------------------------------ 10 Tips for Better Web Security Learn 10 ways to better secure your business today. Topics covered include: Web security, SSL, hacker attacks & Denial of Service (DoS), private keys, security Microsoft Exchange, secure Instant Messaging, and much more. http://www.accelacomm.com/jaw/sfnl/114/51426210/ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
