From: Johnny Billquist <bqt@softjar.se>
Subject: Re: PDP11 Values from MFPT
Date: Wed, 22 Feb 2012 16:26:00 +0100 [thread overview]
Message-ID: <ji31e8$fa1$1@Iltempo.Update.UU.SE> (raw)
In-Reply-To: <4f45dd3a.40560415@nntp.aioe.org>
On 2012-02-22 13.21, paramucho wrote:
> On Tue, 21 Feb 2012 20:43:34 +0100, Johnny Billquist<bqt@softjar.se>
> wrote:
>
>>> System waits ("blocks") may terminate prematurely because of various
>>> conditions, including stuff that ASTs do. So, when a system wait
>>> returns, the routine has to make sure that it's actual condition has
>>> been satisfied, and if it hasn't then it reissues the system wait. The
>>> stack is not a problem.
>>
>> So you need to restart the system call. What if it is a system call that
>> have been partially completed? The wait does not happen as a unique part
>> of the call.
>
> A system wait *is* a unique part of a system call. You don't need to
> restart the system call. The "wait" is a loop which retests a wait
> condition. That's all.
But there is a problem here. Can't you see it?
If you are sitting in a wait loop in the kernel, how do you get back out
to user state in a way that will allow you to get back into the wait
loop with a preserved context, without exposing the kernel to userspace
manipulatio?
Normally this is not a problem, because you do not call out from kernel
to userspace. Userspace do a system call, and eventually it returns. You
do not have code in kernel space escaping back out into userspace, and
then userspace returns back into kernelspace, where execution continues.
Therein lies the problem. From userspace, the system call is a single
instruction. It is either performed, or not. Not half-done. However, by
having the kernel call back out to user space in the middle of a system
call, you both violate that view, and you require kernel context to be
kept around while back in user space, at which time a context switch can
again take place, not to mention other system calls taking place.
So, how do you keep the context for the first system call around when
the next system call happens? And what do you expect to be on the stack?
And what if the second system call also cause a wait? There is a big can
of worms here.
>> Oh, wait, I bet you are thinking in terms of RT-11 here, where the
>> distinction between user mode and kernel mode is rather blurry.
>>
>> In Unix, as an example, there is no context around to restart in the
>> middle of a system call. What you have left is the context at user mode,
>> which is then the start of the system call again.
>> And this is because a signal is delivered in user mode, so the process
>> gets out of the kernel, in order to run the signal handler. There is no
>> way you can keep the kernel context for the user process around at that
>> point. It can not live on the kernel stack, since you exited from the
>> kernel. It can not live on the user stack, since that would allow you to
>> break the security of the kernel.
>
> I don't know anything about Unix internals but I have the feeling that
> it's not a good example because, like RSX, it doesn't have a reentrant
> kernel where RT, RUST and VMS do.
This is not about reentrancy.
And yes, the Unix kernel is reentrant. You can have several processes
doing and blocking on the same system call in parallel.
Since RSX don't really have the scenario at all, it isn't really helpful
to talk about reentrancy in the RSX case. But as far as anything is
concerned, most anything is reentrant in RSX.
But even bring that term up is a red herring.
> I still think your looking at the issue from an RSX angle when you say
> "exited from the kernel", in particular when you say the context "can
> not live on the kernel stack". Kernel and user mode context are both
> active during all process activity. The key piece of kernel
> information to save across the ast is in fact the kernel fp/sp before
> the ast. When an ast exits it returns to a piece of code which issues
> a system call to handle ast exit.
Nope. Since this isn't even a problem in RSX. It is a problem in Unix,
it is a problem in VMS. Both of them have system calls that can be
aborted with the error code that you need to redo the system call again.
Which is the Unix solution to the problem.
Other systems instead backs out and redo the system call after it has
been interrupted.
You seem to be pretty alone in thinking that you can just ignore it.
> There are rules which forbid one or two scenarios. For example, I
> don't think you can run a kernel ast when a user ast is running. In
> such cases the kernel ast is delayed.
Don't know about RT-11, but in VMS, as well as RSX, when one AST is
executing, all other ASTs are blocked for that process. All ASTs are
queued for the process, and kernel ASTs are added to the head of the
queue, while user ASTs are added to the tail.
So all ASTs (no matter which type) are delayed when an AST is in progress.
> However, there is nothing in the VMS sources about restarting system
> calls because of ASTs, or anything else for that matter.
My memory was incorrect. I can't find anything about aborting system
calls because of ASTs. I'll look some more. The only errors meaning
please restart system calls are from resource shortages.
However, VMS can block processes, making them deaf and dumb instead,
which seems to be the normal behavior there. That's all your resource
waits. No wonder VMS have lousy response times. You cannot be sure ASTs
are delivered anywhere near the time they were queued.
And resource waits are basically mutexes for the process. And they can
happen for a number of reasons. And no, you do not break out of a
resource wait just because you get an AST.
In Unix, you get the system call aborted. In VMS, at some sensitive
places you instead have the process go deaf and dumb.
Now, if you consider that better or worse than Unix, I don't know. I
totally dislike both solutions.
>>> In the RT-11 sources you'll see a bunch of calls to $SYSWT which
>>> implement this logic for RT-11. $SYSWT uses co-routines, so they're
>>> even more convoluted than RT-11 usually is.
>>>
>>> I had a look at my RUST/XM system wait code tonight, and I think I
>>> understand it. The "$stall #10$, prwhi" issues the system wait, with
>>> 10$ as the continuation address after the system wait and prwhi.
>>> (hibernation) as the system wait state.
>>>
>>> em$spd:: ;suspend
>>> 10$: mov p$hpcr,r4 ;get the pcr
>>> $float ;stop the scheduler
>>> mov pr.sta(r4),r0 ;get the status
>>> bic #prwak$,pr.sta(r4) ;clear the bit
>>> bit #stact$,p$hast ;are we in an AST?
>>> bne 20$ ;yes - forget the rest
>>> bit #prwak$,r0 ;did we get a wake up?
>>> bne 20$ ;yes
>>> $stall #10$, prwhi. ;hibernate
>>> 20$: $land
>>> return
>>>
>>> em$rsm:: ;resume
>>> mov p$hpcr,r4 ;get the pcr
>>> bis #prwak$,pr.sta(r4) ;set wake pending
>>> return
>>>
>>>> See http://en.wikipedia.org/wiki/PCLSRing for more details.
>>>
>>> That seems to be some other issue.
>>
>> No. It is totally the issue. See my comments above.
>>
>> RT-11 can, however, get away with some things that you cannot do in
>> systems where user mode and kernel mode are totally separate and
>> isolated from each other.
>
> What do you think the (RUST) code above is "getting away with"?
I did not initially even look at your code, since it didn't seem that
relevant. Code in RT-11 in general do not (nor need) the strict
separation between userspace and kernel space. That is what I was
referring to with the "get away with" comment. It is much more ok to
call back from the kernel to the user program in RT-11, since there are
no security considerations to take.
But if I read things right, you get to em$spd when you are about to
suspend a process, and call em$rsm to wake a process up?
So, if you are in an AST, you will never suspend, otherwise you will
unless the wake bit have been set.
There is way too little here to see or comment much more about. How do
you deliver an AST? Where does that happen, and in which context? How is
the AST invoked, and how is it returned from? What happens if you do
system calls in the AST routine? And if those need to block?
> BTW: user mode and kernel mode have the same memory map in VMS. They
> are certainly not totally isolated. In mapped RT-11 and RUST systems
> they are quite separate.
Since in VMS (well, on a VAX anyway, but I assume on all architectures)
you only have one memory map, that is not really relevant. User mode
cannot access, or even see pages in the kernel. And cannot access the
kernel stack. The kernel is totally isolated from the user mode. Kernel
can, however, access all memory of the user. Not really different than
from a PDP-11, even though there you have different mappings depending
on which mode the processor is in.
The only way to get from user mode to kernel mode is by causing a trap,
which the kernel will handle, and then do something (for example a
system call).
You cannot "return" from user mode to kernel mode, or call random
addresses in kernel mode from user mode, or even check any data the
kernel holds.
>> Assuming I'm right, I can see why a lot of discussion and confusion
>> comes up between us. The conditions in RT-11 are rather different than
>> other systems, meaning you can do stuff that is totally impossible in
>> other OSes.
>
> There is a good deal of flexibility unmapped RT-11 systems (e.g.
> RT-11/SJ, RT-11/FB and RUST/SJ), but in the mapped systems (RT-11/XM,
> RUST/XM) much of that flexibility is lost.
I guess some of it must be lost by just having memory being mapped away
in different directions.
Johnny
next prev parent reply other threads:[~2012-02-22 15:26 UTC|newest]
Thread overview: 222+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-01-15 14:37 PDP11 Values from MFPT Jerome H. Fine
2012-01-18 6:03 ` paramucho
2012-01-18 11:28 ` Johnny Billquist
2012-01-18 13:05 ` glen herrmannsfeldt
2012-01-18 13:26 ` Johnny Billquist
2012-01-26 3:24 ` Jerome H. Fine
2012-01-26 13:38 ` Johnny Billquist
2012-01-29 1:32 ` Jerome H. Fine
2012-01-29 1:43 ` Johnny Billquist
2012-01-26 3:23 ` Jerome H. Fine
2012-01-18 16:02 ` paramucho
2012-01-18 18:12 ` Johnny Billquist
2012-01-19 14:30 ` paramucho
2012-01-19 16:42 ` Johnny Billquist
2012-01-19 20:32 ` glen herrmannsfeldt
2012-01-20 13:32 ` paramucho
2012-01-20 13:29 ` paramucho
2012-01-20 16:48 ` Johnny Billquist
2012-01-21 12:25 ` paramucho
2012-01-21 20:15 ` Johnny Billquist
2012-01-26 3:25 ` Jerome H. Fine
2012-01-26 6:09 ` paramucho
2012-01-26 6:30 ` paramucho
2012-01-26 13:50 ` Johnny Billquist
2012-01-29 1:52 ` Jerome H. Fine
2012-01-29 2:08 ` Johnny Billquist
2012-01-26 13:48 ` Johnny Billquist
2012-01-26 13:46 ` Johnny Billquist
2012-01-29 1:35 ` Jerome H. Fine
2012-01-18 12:41 ` glen herrmannsfeldt
2012-01-18 13:18 ` Johnny Billquist
2012-01-18 14:28 ` glen herrmannsfeldt
2012-01-18 15:14 ` Johnny Billquist
2012-01-18 21:54 ` glen herrmannsfeldt
2012-01-18 22:32 ` Al Kossow
2012-01-19 0:22 ` Johnny Billquist
2012-01-19 1:30 ` glen herrmannsfeldt
2012-01-19 14:32 ` Bob Koehler
2012-01-19 16:45 ` Johnny Billquist
2012-01-20 17:55 ` Bob Koehler
2012-01-20 18:38 ` Bill Gunshannon
2012-01-18 16:25 ` paramucho
2012-01-18 18:00 ` Johnny Billquist
2012-01-19 14:25 ` paramucho
2012-01-19 16:50 ` Johnny Billquist
2012-01-20 13:32 ` paramucho
2012-01-20 16:54 ` Johnny Billquist
2012-01-21 13:16 ` paramucho
2012-01-21 13:58 ` Bob Eager
2012-01-21 20:02 ` Johnny Billquist
2012-01-22 11:59 ` Johnny Billquist
2012-01-22 14:03 ` paramucho
2012-01-22 16:15 ` Johnny Billquist
2012-01-23 4:14 ` paramucho
2012-01-18 13:20 ` Bob Eager
2012-01-19 14:29 ` Bob Koehler
2012-01-21 12:44 ` Tim Shoppa
2012-01-21 13:50 ` paramucho
2012-01-22 16:56 ` Tim Shoppa
2012-01-22 18:11 ` glen herrmannsfeldt
2012-01-23 3:52 ` paramucho
2012-01-21 14:25 ` glen herrmannsfeldt
2012-01-21 16:46 ` Bob Eager
2012-01-25 22:12 ` Tim Shoppa
2012-01-26 3:22 ` Jerome H. Fine
2012-01-26 13:46 ` paramucho
2012-01-29 1:34 ` Jerome H. Fine
2012-01-29 15:46 ` paramucho
2012-02-01 3:53 ` Jerome H. Fine
2012-02-01 11:22 ` paramucho
2012-02-01 11:48 ` Johnny Billquist
2012-02-01 13:48 ` paramucho
2012-02-01 14:43 ` stan
2012-02-01 16:37 ` paramucho
2012-02-01 18:05 ` stan
2012-02-02 2:24 ` Jerome H. Fine
2012-02-02 0:14 ` Johnny Billquist
2012-02-02 2:25 ` Jerome H. Fine
2012-02-02 9:29 ` Johnny Billquist
2012-02-02 18:52 ` glen herrmannsfeldt
2012-02-03 0:12 ` Johnny Billquist
2012-02-03 4:07 ` Jerome H. Fine
2012-02-03 14:15 ` Johnny Billquist
2012-02-03 15:00 ` paramucho
2012-02-02 13:31 ` paramucho
2012-02-02 19:07 ` glen herrmannsfeldt
2012-02-03 0:16 ` Johnny Billquist
2012-02-03 4:23 ` glen herrmannsfeldt
2012-02-03 12:01 ` Johnny Billquist
2012-02-03 15:36 ` Joe Oswald
2012-02-07 10:46 ` Johnny Billquist
2012-02-03 4:29 ` Jerome H. Fine
2012-02-03 12:50 ` Bill Gunshannon
2012-02-04 8:42 ` Charles Richmond
2012-02-04 13:38 ` paramucho
2012-02-04 16:03 ` Bill Gunshannon
2012-02-04 16:39 ` paramucho
2012-02-03 10:48 ` paramucho
2012-02-03 11:24 ` Johnny Billquist
2012-02-04 17:06 ` paramucho
2012-02-04 18:22 ` paramucho
2012-02-04 18:55 ` Johnny Billquist
2012-02-04 19:13 ` Bill Gunshannon
2012-02-05 13:28 ` Johnny Billquist
2012-02-05 18:15 ` glen herrmannsfeldt
2012-02-04 18:51 ` Johnny Billquist
2012-02-04 23:09 ` glen herrmannsfeldt
2012-02-05 14:01 ` paramucho
2012-02-05 15:31 ` Johnny Billquist
2012-02-06 13:50 ` paramucho
2012-02-06 14:45 ` Johnny Billquist
2012-02-06 14:58 ` paramucho
2012-02-06 16:25 ` Johnny Billquist
2012-02-05 14:27 ` Johnny Billquist
2012-02-05 13:57 ` paramucho
2012-02-05 15:44 ` Johnny Billquist
2012-02-06 13:51 ` paramucho
2012-02-06 14:56 ` Johnny Billquist
2012-02-06 16:40 ` Johnny Billquist
2012-02-07 14:50 ` paramucho
2012-02-07 16:20 ` Johnny Billquist
2012-02-08 13:34 ` paramucho
2012-02-08 16:03 ` Johnny Billquist
2012-02-08 16:58 ` paramucho
2012-02-08 22:29 ` Johnny Billquist
2012-02-10 13:12 ` paramucho
2012-02-10 19:20 ` glen herrmannsfeldt
2012-02-11 13:12 ` paramucho
2012-02-11 20:06 ` glen herrmannsfeldt
2012-02-11 20:23 ` Johnny Billquist
2012-02-10 19:29 ` Johnny Billquist
2012-02-11 13:15 ` paramucho
2012-02-11 21:09 ` Johnny Billquist
2012-02-12 17:23 ` paramucho
2012-02-12 18:35 ` paramucho
2012-02-13 17:30 ` paramucho
2012-02-14 13:14 ` Johnny Billquist
2012-02-14 16:20 ` paramucho
2012-02-14 17:30 ` Johnny Billquist
2012-02-13 23:18 ` Johnny Billquist
2012-02-14 16:20 ` paramucho
2012-02-14 17:47 ` Johnny Billquist
2012-02-14 18:17 ` paramucho
2012-02-14 19:54 ` Johnny Billquist
2012-02-15 12:58 ` paramucho
2012-02-15 17:12 ` Johnny Billquist
2012-02-16 13:54 ` paramucho
2012-02-16 20:15 ` Johnny Billquist
2012-02-17 12:41 ` paramucho
2012-02-17 17:13 ` Johnny Billquist
2012-02-18 11:24 ` Johnny Billquist
2012-02-18 14:28 ` paramucho
2012-02-18 20:07 ` Johnny Billquist
2012-02-18 11:55 ` paramucho
2012-02-18 20:58 ` Johnny Billquist
2012-02-20 2:29 ` Jerome H. Fine
2012-02-20 5:54 ` paramucho
2012-02-20 17:14 ` Jerome H. Fine
2012-02-20 18:05 ` Johnny Billquist
2012-02-21 6:16 ` paramucho
2012-02-21 17:38 ` Jerome H. Fine
2012-02-21 19:31 ` Johnny Billquist
2012-02-20 5:53 ` paramucho
2012-02-20 10:28 ` Johnny Billquist
2012-02-21 3:33 ` Jerome H. Fine
2012-02-21 6:17 ` paramucho
2012-02-21 10:23 ` Johnny Billquist
2012-02-21 11:37 ` paramucho
2012-02-21 14:16 ` Johnny Billquist
2012-02-21 16:42 ` paramucho
2012-02-21 19:43 ` Johnny Billquist
2012-02-22 12:21 ` paramucho
2012-02-22 14:12 ` paramucho
2012-02-22 15:26 ` Johnny Billquist [this message]
2012-02-22 14:33 ` paramucho
2012-02-22 15:53 ` Johnny Billquist
2012-02-22 16:48 ` paramucho
2012-02-22 21:17 ` Johnny Billquist
2012-02-23 12:42 ` paramucho
2012-02-23 13:51 ` paramucho
2012-02-23 15:17 ` Johnny Billquist
2012-02-20 2:22 ` Jerome H. Fine
2012-02-20 6:07 ` paramucho
2012-02-21 3:29 ` Jerome H. Fine
2012-02-21 8:06 ` paramucho
2012-02-21 10:38 ` Johnny Billquist
2012-02-21 11:54 ` paramucho
2012-02-21 14:20 ` Johnny Billquist
2012-02-21 15:13 ` paramucho
2012-02-21 15:20 ` Johnny Billquist
2012-02-22 2:51 ` Jerome H. Fine
2012-02-22 6:37 ` paramucho
2012-01-18 11:20 ` Johnny Billquist
2012-01-26 3:21 ` Jerome H. Fine
2012-01-26 14:12 ` Johnny Billquist
2012-01-26 15:26 ` paramucho
2012-01-29 1:41 ` Jerome H. Fine
2012-01-29 2:04 ` Johnny Billquist
2012-01-29 2:31 ` Johnny Billquist
2012-01-29 1:39 ` Jerome H. Fine
2012-01-29 1:45 ` Johnny Billquist
2012-01-30 2:21 ` Bob Supnik
2012-01-31 7:14 ` paramucho
2012-01-31 9:42 ` Johnny Billquist
2012-01-31 14:24 ` Bill Gunshannon
2012-01-31 20:17 ` Johnny Billquist
2012-01-31 21:39 ` Bill Gunshannon
2012-01-31 23:43 ` glen herrmannsfeldt
2012-02-01 3:56 ` Jerome H. Fine
2012-02-01 11:53 ` Johnny Billquist
2012-02-01 13:48 ` paramucho
2012-02-02 0:20 ` Johnny Billquist
2012-02-02 2:22 ` Jerome H. Fine
2012-02-01 12:14 ` Johnny Billquist
2012-02-01 16:27 ` glen herrmannsfeldt
2012-02-01 5:28 ` Charles Richmond
2012-02-01 11:54 ` Johnny Billquist
2012-02-01 3:55 ` Jerome H. Fine
2012-02-01 11:22 ` paramucho
2012-02-01 12:03 ` Johnny Billquist
2012-02-01 3:54 ` Jerome H. Fine
2012-02-01 12:09 ` Johnny Billquist
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox