From: Wanlong Gao <gaowanlong@cn.fujitsu.com>
To: DAN LI <li.dan@cn.fujitsu.com>
Cc: LTP list <ltp-list@lists.sourceforge.net>
Subject: Re: [LTP] [PATCH] pthread_cond_brodcast/1-2.c hung when mem left is not enough
Date: Mon, 06 Aug 2012 17:25:52 +0800 [thread overview]
Message-ID: <501F8DA0.6030104@cn.fujitsu.com> (raw)
In-Reply-To: <501A3EA1.4010902@cn.fujitsu.com>
On 08/02/2012 04:47 PM, DAN LI wrote:
> 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 <li.dan@cn.fujitsu.com>
> ---
> .../interfaces/pthread_cond_broadcast/1-2.c | 39 +++++++++++++++++++---
> 1 file changed, 35 insertions(+), 4 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c
> index f6ad9df..14bda10 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_cond_broadcast/1-2.c
> @@ -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;
make these static.
>
> #define TIMEOUT (180)
>
> @@ -243,6 +244,34 @@ void *timer(void *arg)
> return NULL; /* For compiler */
> }
>
> +int decide_process_children_count(void)
static
> +{
> + 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;
need space around "/"
> + 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
> + 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
> --
> 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
> Ltp-list@lists.sourceforge.net
> 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
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2012-08-06 9:27 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-02 8:47 [LTP] [PATCH] pthread_cond_brodcast/1-2.c hung when mem left is not enough DAN LI
2012-08-06 9:25 ` Wanlong Gao [this message]
2012-08-07 2:36 ` [LTP] [PATCH v2] " DAN LI
2012-08-07 3:02 ` Wanlong Gao
2012-08-07 5:45 ` [LTP] [PATCH v3] " DAN LI
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=501F8DA0.6030104@cn.fujitsu.com \
--to=gaowanlong@cn.fujitsu.com \
--cc=li.dan@cn.fujitsu.com \
--cc=ltp-list@lists.sourceforge.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox