pthread_cond_brodcast/1-2.c hung when mem left is not enough
PATCH 1/1 pthread_cond_brodcast/1-2.c hung when mem left is not enough
pthread_cond_brodcast/1-2.c try to create as many childrens(thread or process) as possible,however,if current free memoryis exhausted before all childrens are started,the case will timeout and hung since it's stated with program "t0".
The patch adjust count of childrens according tojudgement of size of current free memory.
--- .../interfaces/pthread_cond_broadcast/1-2.c | 39 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +35 -4
@@ -48,6 +48,7 @@#include <sys/mman.h> #include <sys/wait.h> #include <semaphore.h> +#include <sys/sysinfo.h> #include "../testfrmw/testfrmw.h" #include "../testfrmw/testfrmw.c"
@@ -82,8 +83,8 @@#endif /* Do not create more than this amount of children: */ -#define MAX_PROCESS_CHILDREN (200) -#define MAX_THREAD_CHILDREN (1000) +int max_process_children =200 ; +int max_thread_children =1000 ;#define TIMEOUT (180)
@@ -243,6 +244,34 @@ void *timer(void *arg)return NULL ;/* For compiler */ } +int decide_process_children_count (void ) +{ +struct sysinfo sysinforma; +int ret; +int avail_count; +unsigned long memper; +unsigned long min_stack; + + min_stack =sysconf (_SC_THREAD_STACK_MIN); + + ret =sysinfo (&sysinforma); +if (ret !=0 ) +UNRESOLVED (ret,"Failed to get system infomation." ); + + memper = min_stack * max_thread_children; +if (memper > sysinforma.freeram) +UNTESTED ("Free ram not enough for test." ); + + avail_count = sysinforma.freeram/memper; +if (avail_count <10 ) +UNTESTED ("Free ram not enough for test." ); + + max_process_children = (avail_count<max_process_children ? + avail_count : max_process_children); + +return 0 ; +} +int main (int argc,char *argv[]) {int ret;
@@ -268,6 +297,8 @@ int main(int argc, char *argv[])output_init (); +decide_process_children_count (); +/* check the system abilities */ pshared =sysconf (_SC_THREAD_PROCESS_SHARED); cs =sysconf (_SC_CLOCK_SELECTION);
@@ -476,7 +507,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_THREAD_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_thread_children));#if VERBOSE >2 output ("[parent] Created %i children threads\n" , child_count);#endif
@@ -504,7 +535,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_PROCESS_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_process_children));#if VERBOSE >2 output ("[parent] Created %i children processes\n" , child_count);#endif
Signature · 1 line
1.7.11.rc0
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 25 lines · DAN LI
pthread_cond_brodcast/1-2.c try to create as many childrens(thread or process) as possible,however,if current free memory is exhausted before all childrens are started,the case will timeout and hung since it's stated with program "t0".
The patch adjust count of childrens according to judgement of size of current free memory.
Signed-off-by DAN LI <[email protected]>--- .../interfaces/pthread_cond_broadcast/1-2.c | 39 +++++++++++++++++++--- 1 file changed, 35 insertions(+), 4 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +1
-0@@ -48,6 +48,7 @@#include <sys/mman.h> #include <sys/wait.h> #include <semaphore.h> +#include <sys/sysinfo.h> #include "../testfrmw/testfrmw.h" #include "../testfrmw/testfrmw.c"
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c line 87
Quoted 7 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +2
-2@@ -82,8 +83,8 @@#endif /* Do not create more than this amount of children: */ -#define MAX_PROCESS_CHILDREN (200) -#define MAX_THREAD_CHILDREN (1000) +int max_process_children =200 ; +int max_thread_children =1000 ;
make these static.
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c void *timer(void *arg) · line 247
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +1
-0#define TIMEOUT (180)@@ -243,6 +244,34 @@ void *timer(void *arg)return NULL ;/* For compiler */ } +int decide_process_children_count (void )
static
Quoted 8 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +8
-0+{ +struct sysinfo sysinforma; +int ret; +int avail_count; +unsigned long memper; +unsigned long min_stack; + + min_stack =sysconf (_SC_THREAD_STACK_MIN);
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c void *timer(void *arg) · line 265
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +10
-0+ + ret =sysinfo (&sysinforma); +if (ret !=0 ) +UNRESOLVED (ret,"Failed to get system infomation." ); + + memper = min_stack * max_thread_children; +if (memper > sysinforma.freeram) +UNTESTED ("Free ram not enough for test." ); + + avail_count = sysinforma.freeram/memper;
need space around "/"
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c void *timer(void *arg) · line 269
Quoted 4 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +4
-0+if (avail_count <10 ) +UNTESTED ("Free ram not enough for test." ); + + max_process_children = (avail_count<max_process_children ?
space around "<"
Please check your coding style before sending out the patch.
Thanks,
Wanlong Gao
Quoted 54 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +9
-2+ avail_count : max_process_children); + +return 0 ; +} +int main (int argc,char *argv[]) {int ret;@@ -268,6 +297,8 @@ int main(int argc, char *argv[])output_init (); +decide_process_children_count (); +/* check the system abilities */ pshared =sysconf (_SC_THREAD_PROCESS_SHARED); cs =sysconf (_SC_CLOCK_SELECTION);@@ -476,7 +507,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_THREAD_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_thread_children));#if VERBOSE >2 output ("[parent] Created %i children threads\n" , child_count);#endif @@ -504,7 +535,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_PROCESS_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_process_children));#if VERBOSE >2 output ("[parent] Created %i children processes\n" , child_count);#endif Signature · 17 lines
1.7.11.rc0 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v2 1/1 pthread_cond_brodcast/1-2.c hung when mem left is not enough
pthread_cond_brodcast/1-2.c try to create as many childrens(thread or process) as possible,however,if current free memoryis exhausted before all childrens are started,the case will timeout and hung since it's stated with program "t0".
The patch adjust count of childrens according to judgement of size of current free memory.
--- .../interfaces/pthread_cond_broadcast/1-2.c | 39 ++++++++++++++++++-- 1 files changed, 35 insertions(+), 4 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +35 -4
@@ -48,6 +48,7 @@#include <sys/mman.h> #include <sys/wait.h> #include <semaphore.h> +#include <sys/sysinfo.h> #include "../testfrmw/testfrmw.h" #include "../testfrmw/testfrmw.c"
@@ -82,8 +83,8 @@#endif /* Do not create more than this amount of children: */ -#define MAX_PROCESS_CHILDREN (200) -#define MAX_THREAD_CHILDREN (1000) +static int max_process_children =200 ; +static int max_thread_children =1000 ;#define TIMEOUT (180)
@@ -242,6 +243,34 @@ void *timer(void *arg)FAILED_KILLALL ("Operation timed out. A signal was lost." );return NULL ;/* For compiler */ } +static int decide_process_children_count (void ) +{ +struct sysinfo sysinforma; +int ret; +int avail_count; +unsigned long memper; +unsigned long min_stack; + + min_stack =sysconf (_SC_THREAD_STACK_MIN); + + ret =sysinfo (&sysinforma); +if (ret !=0 ) +UNRESOLVED (ret,"Failed to get system infomation." ); + + memper = min_stack * max_thread_children; +if (memper > sysinforma.freeram) +UNTESTED ("Free ram not enough for test." ); + + avail_count = sysinforma.freeram / memper; + +if (avail_count <10 ) +UNTESTED ("Free ram not enough for test." ); + + max_process_children = (avail_count < max_process_children ? + avail_count : max_process_children); + +return 0 ; +}int main (int argc,char *argv[]) {
@@ -268,6 +297,8 @@ int main(int argc, char *argv[])output_init (); +decide_process_children_count (); +/* check the system abilities */ pshared =sysconf (_SC_THREAD_PROCESS_SHARED); cs =sysconf (_SC_CLOCK_SELECTION);
@@ -476,7 +507,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_THREAD_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_thread_children));#if VERBOSE >2 output ("[parent] Created %i children threads\n" , child_count);#endif
@@ -504,7 +535,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_PROCESS_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_process_children));#if VERBOSE >2 output ("[parent] Created %i children processes\n" , child_count);#endif
Signature · 1 line
1.7.7.6
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
Quoted 40 lines · DAN LI
pthread_cond_brodcast/1-2.c try to create as many childrens(thread or process) as possible,however,if current free memory is exhausted before all childrens are started,the case will timeout and hung since it's stated with program "t0".
The patch adjust count of childrens according to judgement of size of current free memory.
Signed-off-by DAN LI <[email protected]>--- .../interfaces/pthread_cond_broadcast/1-2.c | 39 ++++++++++++++++++-- 1 files changed, 35 insertions(+), 4 deletions(-)testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +4
-2@@ -48,6 +48,7 @@#include <sys/mman.h> #include <sys/wait.h> #include <semaphore.h> +#include <sys/sysinfo.h> #include "../testfrmw/testfrmw.h" #include "../testfrmw/testfrmw.c" @@ -82,8 +83,8 @@#endif /* Do not create more than this amount of children: */ -#define MAX_PROCESS_CHILDREN (200) -#define MAX_THREAD_CHILDREN (1000) +static int max_process_children =200 ; +static int max_thread_children =1000 ;#define TIMEOUT (180)@@ -242,6 +243,34 @@ void *timer(void *arg)FAILED_KILLALL ("Operation timed out. A signal was lost." );return NULL ;/* For compiler */ } +static int decide_process_children_count (void )
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c void *timer(void *arg) · line 256
Quoted 10 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +10
-0+{ +struct sysinfo sysinforma; +int ret; +int avail_count; +unsigned long memper; +unsigned long min_stack; + + min_stack =sysconf (_SC_THREAD_STACK_MIN); + + ret =sysinfo (&sysinforma);
This is a linux specific function, so you can define this function like this
#ifdef __linux__
static void decide_xxx(void)
{
xxx
xxx
}
#else
static void decide_xxx(void)
{
return;
}#endif
Thanks,
Wanlong Gao
Quoted 50 lines
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +21
-2+if (ret !=0 ) +UNRESOLVED (ret,"Failed to get system infomation." ); + + memper = min_stack * max_thread_children; +if (memper > sysinforma.freeram) +UNTESTED ("Free ram not enough for test." ); + + avail_count = sysinforma.freeram / memper; + +if (avail_count <10 ) +UNTESTED ("Free ram not enough for test." ); + + max_process_children = (avail_count < max_process_children ? + avail_count : max_process_children); + +return 0 ; +}int main (int argc,char *argv[]) {@@ -268,6 +297,8 @@ int main(int argc, char *argv[])output_init (); +decide_process_children_count (); +/* check the system abilities */ pshared =sysconf (_SC_THREAD_PROCESS_SHARED); cs =sysconf (_SC_CLOCK_SELECTION);@@ -476,7 +507,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_THREAD_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_thread_children));#if VERBOSE >2 output ("[parent] Created %i children threads\n" , child_count);#endif @@ -504,7 +535,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_PROCESS_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_process_children));#if VERBOSE >2 output ("[parent] Created %i children processes\n" , child_count);#endif Signature · 1 line
1.7.7.6
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
PATCH v3 1/1 pthread_cond_brodcast/1-2.c hung when mem left is not enough
--- .../interfaces/pthread_cond_broadcast/1-2.c | 47 ++++++++++++++++++-- 1 files changed, 43 insertions(+), 4 deletions(-)
testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c +43 -4
@@ -48,6 +48,7 @@#include <sys/mman.h> #include <sys/wait.h> #include <semaphore.h> +#include <sys/sysinfo.h> #include "../testfrmw/testfrmw.h" #include "../testfrmw/testfrmw.c"
@@ -82,8 +83,8 @@#endif /* Do not create more than this amount of children: */ -#define MAX_PROCESS_CHILDREN (200) -#define MAX_THREAD_CHILDREN (1000) +static int max_process_children =200 ; +static int max_thread_children =1000 ;#define TIMEOUT (180)
@@ -243,6 +244,42 @@ void *timer(void *arg)return NULL ;/* For compiler */ } +#ifdef __linux__ +static void decide_process_children_count (void ) +{ +struct sysinfo sysinforma; +int ret; +int avail_count; +unsigned long memper; +unsigned long min_stack; + + min_stack =sysconf (_SC_THREAD_STACK_MIN); + + ret =sysinfo (&sysinforma); +if (ret !=0 ) +UNRESOLVED (ret,"Failed to get system infomation." ); + + memper = min_stack * max_thread_children; +if (memper > sysinforma.freeram) +UNTESTED ("Free ram not enough for test." ); + + avail_count = sysinforma.freeram / memper; + +if (avail_count <10 ) +UNTESTED ("Free ram not enough for test." ); + + max_process_children = (avail_count < max_process_children ? + avail_count : max_process_children); + +return ; +} +#else +static void decide_process_children_count (void ) +{ +return ; +} +#endif +int main (int argc,char *argv[]) {int ret;
@@ -268,6 +305,8 @@ int main(int argc, char *argv[])output_init (); +decide_process_children_count (); +/* check the system abilities */ pshared =sysconf (_SC_THREAD_PROCESS_SHARED); cs =sysconf (_SC_CLOCK_SELECTION);
@@ -476,7 +515,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_THREAD_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_thread_children));#if VERBOSE >2 output ("[parent] Created %i children threads\n" , child_count);#endif
@@ -504,7 +543,7 @@ int main(int argc, char *argv[]) }else { ret = errno; } - }while ((ret ==0 ) && (child_count <MAX_PROCESS_CHILDREN )); + }while ((ret ==0 ) && (child_count < max_process_children));#if VERBOSE >2 output ("[parent] Created %i children processes\n" , child_count);#endif
Signature · 14 lines
1.7.7.6 ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Ltp-list mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/ltp-list