From: chrubis@suse.cz
To: Jan Stancek <jstancek@redhat.com>
Cc: ltp-list@lists.sourceforge.net
Subject: Re: [LTP] [PATCH 3/3] pthread_attr_setschedpolicy/2-1.c: give threads a moment to block on mutex
Date: Thu, 3 Oct 2013 14:38:34 +0200 [thread overview]
Message-ID: <20131003123834.GC3516@rei.Home> (raw)
In-Reply-To: <ac99f1c859b7e69d93ed09bc9223f2aabf325a5a.1380794505.git.jstancek@redhat.com>
Hi!
> Use small sleep for lack of better way to check that all threads
> are blocked on mutex "mutex".
>
> Signed-off-by: Jan Stancek <jstancek@redhat.com>
> ---
> .../interfaces/pthread_attr_setschedpolicy/2-1.c | 3 +++
> 1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c
> index 80ce906..1f8825a 100644
> --- a/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c
> +++ b/testcases/open_posix_testsuite/conformance/interfaces/pthread_attr_setschedpolicy/2-1.c
> @@ -161,6 +161,9 @@ int main(void)
> if (rc)
> FAIL_AND_EXIT("create_thread HIGH", rc);
>
> + /* give threads a moment so they can block on mutex "mutex" */
> + sleep(2);
> +
> rc = pthread_mutex_unlock(&mutex);
> if (rc)
> FAIL_AND_EXIT("pthread_mutex_unlock()", rc);
Hmm, so you did hit the small window for race condition between the new
thread signals the main thread that it's executed and the next call to
the mutex_lock on the tested mutex?
I do not like this solution much, but this is not easy to do properly.
One posibility is to pinpoint the threads on one cpu via the affinity()
interface (open_posix_testsuite/include/affinity.h) then we can wait in
the main thread until the thread with lowest priority is executed and
safely say that the rest is locked on the mutex allready (as they run
with FIFO scheduling).
--
Cyril Hrubis
chrubis@suse.cz
------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60134791&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list
next prev parent reply other threads:[~2013-10-03 12:38 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-10-03 11:32 [LTP] [PATCH 1/3] pthread_attr_setschedpolicy/2-1.c: simplify error handling Jan Stancek
2013-10-03 11:32 ` [LTP] [PATCH 2/3] pthread_attr_setschedpolicy/2-1.c: fix race at thread startup Jan Stancek
2013-10-03 12:23 ` chrubis
2013-10-03 11:32 ` [LTP] [PATCH 3/3] pthread_attr_setschedpolicy/2-1.c: give threads a moment to block on mutex Jan Stancek
2013-10-03 12:38 ` chrubis [this message]
[not found] ` <997090639.1023118.1380805094088.JavaMail.root@redhat.com>
2013-10-03 13:13 ` chrubis
[not found] ` <1572642675.1045335.1380806767492.JavaMail.root@redhat.com>
2013-10-03 13:46 ` chrubis
2013-10-04 6:47 ` [LTP] [PATCH v2 3/3] pthread_attr_setschedpolicy/2-1.c: bind threads to single CPU Jan Stancek
2013-10-14 12:00 ` chrubis
2013-10-03 12:03 ` [LTP] [PATCH 1/3] pthread_attr_setschedpolicy/2-1.c: simplify error handling chrubis
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=20131003123834.GC3516@rei.Home \
--to=chrubis@suse.cz \
--cc=jstancek@redhat.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