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 15:46:39 +0200 [thread overview]
Message-ID: <20131003134639.GA4048@rei.Home> (raw)
In-Reply-To: <1572642675.1045335.1380806767492.JavaMail.root@redhat.com>
Hi!
> > > 2. linux default sched_rt_runtime_us gives 0.05s to be used by
> > > SCHED_OTHER (non-RT tasks) (Documentation/scheduler/sched-rt-group.txt)
> > > If we set also main thread to use SCHED_FIFO, then this shouldn't be
> > > problem.
> >
> > That shouldn't be much of problem, the main thread would pick up once
> > the realtime threads are locked on mutexes/cond vars. Or am I mistaken
> > here?
>
> (assuming all threads are bound to single CPU)
> That's true, but (the way I understand it) non-rt main thread can also run
> when scheduler thinks that RT processes are monopolizing CPU for too long.
As I understand it, it's a anti lockup measure so if the kernel detects
that realtime threads has been running for nearly a second in a row it
stops the execution and schedules some other threads. But that shouldn't
be the case here.
> So you can't be sure that thread is actually on "mutex".
>
> thread_func():
> pthread_mutex_lock(&c_mutex);
> pthread_cond_signal(&cond);
> pthread_mutex_unlock(&c_mutex);
> --> here scheduler decides it's time to give a chance to non-rt threads
> and runs main thread, condition was already signalled so main thinks
> thread is already blocking on mutex
> pthread_mutex_lock(&mutex);
>
> If we set SCHED_FIFO also on main thread with lowest priority, then
> it shouldn't run regardless of value in sched_rt_runtime_us.
That is why I said that we have to wait for the lowest priority thread
to run. Giving the main thread even lower priority is a way of doing
that.
--
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 13:46 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
[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 [this message]
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=20131003134639.GA4048@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