linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: john cooper <john.cooper@timesys.com>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Mark Johnson <Mark_H_Johnson@RAYTHEON.COM>,
	Ingo Molnar <mingo@elte.hu>, Amit Shah <amit.shah@codito.com>,
	Karsten Wiese <annabellesgarden@yahoo.de>,
	Bill Huey <bhuey@lnxw.com>, Adam Heath <doogie@debian.org>,
	emann@mrv.com, Gunther Persoons <gunther_persoons@spymac.com>,
	"K.R. Foley" <kr@cybsft.com>, LKML <linux-kernel@vger.kernel.org>,
	Florian Schmidt <mista.tapas@gmx.net>,
	Fernando Pablo Lopez-Lezcano <nando@ccrma.Stanford.EDU>,
	Lee Revell <rlrevell@joe-job.com>,
	Rui Nuno Capela <rncbc@rncbc.org>,
	Shane Shrybman <shrybman@aei.ca>,
	Esben Nielsen <simlo@phys.au.dk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Michal Schmidt <xschmi00@stud.feec.vutbr.cz>,
	john cooper <john.cooper@timesys.com>
Subject: Re: [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm3-V0.7.32-6
Date: Tue, 14 Dec 2004 09:28:19 -0500	[thread overview]
Message-ID: <41BEF883.9000401@timesys.com> (raw)
In-Reply-To: <1103029296.3582.28.camel@localhost.localdomain>

Steven Rostedt wrote:

> Why must the server be non-preemptable?  Have you written code for a
> server that can immediately switch to another clients request? I've
> tried, and it's not easy.

Yes I have and agree it is not trivial.  What is required is
for the server's context in the process of servicing client A
to be saved with A and context of the new client to be loaded.

One way this can be accomplished is to save the server context
on the stack of the client which it is preempting.  This is
quite similar to the model of a CPU (server) and how task
(client) preemption is effected in the kernel.

> The work of the server would only process one
> client at a time. In that regard, the server is "non-preemptable", but
> in services to be done, not in context switching. B would preempt server
> S just because B is a higher priority. But when B puts itself to sleep
> on S's wait queue, S would then inherit B's priority.

In this scenario B is not preempting A's service, but rather elevating
S to the priority of B in hope S can compete for system resource at
B's priority.  In a preemptive scenario B would not sleep on S as its
priority would redirect S from A to B.  The only time an arriving high
priority client would promote/block over preemption would be if S
itself was blocked (unavailable).

> But S would still
> be finishing A's work. When S finished A's work, it would go directly on
> to B's work.  This is just like a mutex...

Yes the above is just like a mutex.  However the model of a server
thread offers opportunity for greater server (resource) availability
while retaining correct semantics vs. that of a mutex (resource).
The server's service of a client in general may be preempted while
the ownership of a mutex may not.

> Server S would not know that B is on the wait queue, except that B has
> increased S's priority. S would still work on A's request, so the only
> saving for S would be in the S's stack when B preempted it.

True in the non-preemptive case as there is no reason to
notify S.  In the preemptive case S would receive the
equivalent of an interrupt upon B's arrival.

> How would you redirect the Server?  If server S is working on A's work,
> (let's make it easy and use the example of a web server) A sends S a
> request to serve page P, S goes to retrieve P, then B comes along and
> request page Q, how would you write the code to know to stop working on
> getting P and start getting Q, S is a single thread, doing the work, not
> multiple instances.

True.  However abstractly S would be preempted and save its
current context 'with' A.  S then would restore (load) B's
(initial) context and begin service.

A userspace example is probably not the easiest place to start.
Such saving and restoration of context is much less of a logistical
issue for in-kernel mechanisms.

Although I've implemented similar server models in userspace where
the available server interruptive mechanism boils down to sending
of a signal.  The enforcement of critical sections in the
server is effected by blocking signal delivery (preemption).

> If you have a single thread working as the server, how do you go about
> writing code that can have that thread stop a task in the middle and
> start doing something else. Although there may not be a need to do
> certain things non-preemptively, but a server (should I say server
> thread), only does one task at a time, giving it a same functionality as
> a mutex.

The server in the preemptive model virtualizes a CPU.  We can
preempt the service of the CPU during execution in a task (client)
by interrupting the CPU.  This results in saving of the CPU context
during the service of the client on the stack of the preempted client.

> I agree with you here, since a process can only have one server working
> on it at a time. But this can become a problem, if you have one server
> working for another server. If server S needs something from server X
> then X needs something from server S, and they both are waiting. But
> that would already have shown up in the kernel.

Yes, circular dependencies are illegal while strictly ordered
dependencies are allowable.  This is similar to enforcement of
a mutex/lock acquisition hierarchy.

> The whole point I'm trying to make is that today, when a high priority
> process goes onto a wait queue, the process that will server that rt
> process may be of a lower priority than other processes lower that the
> original rt process that is waiting.  So you have a case of priority
> inversion within processes serving other processes.

Agreed.  And I do think this mechanism has merit irrespective
of the preemption model -- I wouldn't expect a preemptive
approach to be available in the first prototype.

I'd hazard other likely sources of battle history dealing with
client/server/preemption issues to be found in papers dealing with
microkernel [who?] design of about a decade and a half ago.

-john


-- 
john.cooper@timesys.com

  reply	other threads:[~2004-12-14 14:31 UTC|newest]

Thread overview: 72+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-09 18:10 [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm3-V0.7.32-6 Mark_H_Johnson
2004-12-09 19:40 ` Ingo Molnar
2004-12-09 19:58 ` Ingo Molnar
2004-12-10 23:42 ` Steven Rostedt
2004-12-11 16:59   ` john cooper
2004-12-12  4:36     ` Steven Rostedt
2004-12-13 23:45       ` john cooper
2004-12-14 13:01         ` Steven Rostedt
2004-12-14 14:28           ` john cooper [this message]
2004-12-14 16:53             ` Steven Rostedt
2004-12-11 17:59   ` Esben Nielsen
2004-12-11 18:59     ` Steven Rostedt
2004-12-11 19:50       ` Esben Nielsen
2004-12-11 22:34         ` Steven Rostedt
2004-12-13 21:55           ` Bill Huey
2004-12-13 22:15             ` Steven Rostedt
2004-12-13 22:20               ` Ingo Molnar
2004-12-13 22:31   ` Ingo Molnar
  -- strict thread matches above, loose matches on Subject: below --
2004-12-13 14:10 Mark_H_Johnson
2004-12-09 21:58 Mark_H_Johnson
2004-12-09 22:55 ` Ingo Molnar
2004-12-09 20:49 Mark_H_Johnson
2004-12-09 21:56 ` Ingo Molnar
2004-12-09 20:38 Mark_H_Johnson
2004-12-09 19:54 Mark_H_Johnson
2004-12-09 19:23 Mark_H_Johnson
2004-12-09 20:04 ` Ingo Molnar
2004-12-10  5:01 ` Bill Huey
2004-12-10  5:14   ` Steven Rostedt
2004-12-10  5:58     ` Bill Huey
2004-12-09 18:15 Mark_H_Johnson
2004-12-09 20:11 ` Ingo Molnar
2004-12-09 17:22 Mark_H_Johnson
2004-12-09 17:31 ` Ingo Molnar
2004-12-09 20:34   ` K.R. Foley
2004-12-09 22:06     ` Ingo Molnar
2004-12-09 23:16       ` K.R. Foley
2004-12-10  4:26       ` K.R. Foley
2004-12-10 11:22         ` Ingo Molnar
2004-12-10 15:26           ` K.R. Foley
2004-12-09 16:56 Mark_H_Johnson
2004-12-09 17:28 ` Ingo Molnar
2004-12-09 17:41 ` Ingo Molnar
2004-12-09 18:26 ` Ingo Molnar
2004-12-09 19:04 ` Esben Nielsen
2004-12-09 19:58   ` john cooper
2004-12-09 20:16   ` Lee Revell
2004-12-09 15:16 Mark_H_Johnson
2004-12-09 16:17 ` Florian Schmidt
2004-12-09 17:13 ` Ingo Molnar
2004-12-09 14:46 Mark_H_Johnson
2004-12-09 14:14 Mark_H_Johnson
2004-12-07 21:41 Mark_H_Johnson
2004-11-16 13:09 [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm1-V0.7.27-1 Ingo Molnar
2004-11-16 13:40 ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm1-V0.7.27-3 Ingo Molnar
2004-11-17 12:42   ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm1-V0.7.28-0 Ingo Molnar
2004-11-18 12:35     ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm1-V0.7.28-1 Ingo Molnar
2004-11-18 16:46       ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm2-V0.7.29-0 Ingo Molnar
2004-11-22  0:54         ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm2-V0.7.30-2 Ingo Molnar
2004-11-23 17:58           ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm2-V0.7.30-9 Ingo Molnar
2004-11-24 10:16             ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm2-V0.7.30-10 Ingo Molnar
2004-12-03 20:58               ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm2-V0.7.32-0 Ingo Molnar
2004-12-07 13:29                 ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm3-V0.7.32-4 Ingo Molnar
2004-12-07 14:11                   ` [patch] Real-Time Preemption, -RT-2.6.10-rc2-mm3-V0.7.32-6 Ingo Molnar
2004-12-08  4:31                     ` K.R. Foley
2004-12-08  8:34                       ` Ingo Molnar
2004-12-08 16:07                         ` K.R. Foley
2004-12-08 16:18                           ` Lee Revell
2004-12-08 16:52                             ` K.R. Foley
2004-12-08 16:58                               ` Lee Revell
2004-12-09  9:02                               ` Ingo Molnar
2004-12-09  2:45                           ` K.R. Foley
2004-12-09 12:11                             ` Ingo Molnar
2004-12-09 14:50                               ` K.R. Foley
2004-12-08 17:13                     ` Steven Rostedt
2004-12-08 18:14                       ` Rui Nuno Capela
2004-12-08 19:03                         ` Steven Rostedt
2004-12-08 21:39                           ` Rui Nuno Capela
2004-12-08 22:11                             ` Steven Rostedt
2004-12-09  9:32                               ` Ingo Molnar
2004-12-09 13:36                                 ` Steven Rostedt
2004-12-09  9:06                       ` Ingo Molnar

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=41BEF883.9000401@timesys.com \
    --to=john.cooper@timesys.com \
    --cc=Mark_H_Johnson@RAYTHEON.COM \
    --cc=amit.shah@codito.com \
    --cc=annabellesgarden@yahoo.de \
    --cc=bhuey@lnxw.com \
    --cc=doogie@debian.org \
    --cc=emann@mrv.com \
    --cc=gunther_persoons@spymac.com \
    --cc=kr@cybsft.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=mista.tapas@gmx.net \
    --cc=nando@ccrma.Stanford.EDU \
    --cc=rlrevell@joe-job.com \
    --cc=rncbc@rncbc.org \
    --cc=rostedt@goodmis.org \
    --cc=shrybman@aei.ca \
    --cc=simlo@phys.au.dk \
    --cc=tglx@linutronix.de \
    --cc=xschmi00@stud.feec.vutbr.cz \
    /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;
as well as URLs for NNTP newsgroup(s).