On 2022-08-16 19:54, Simon Clubley wrote:
> On 2022-08-15, Johnny Billquist <
b...@softjar.se> wrote:
>> On 2022-08-15 19:28, Simon Clubley wrote:
>>> Unix/Linux sets up a new process to run an image and then deletes
>>> it immediately afterwards and has no such thing as P1 space.
>>
>> Yes.
>> Well, technically, P1 space is an artifact of the hardware, and as such,
>> P1 space exists also for Unix systems running on VAX, and possibly also
>> Alpha.
>>
>> VMS just keeps P1 space around a bit more disconnected from the program
>> you might be executing.
>>
>
> It's what VMS does with that address space that makes it so different
> from other operating systems.
It's certainly been a long time since I looked inside VMS. Which I get
called out on every time I make some mistake/assumption/remember things
wrong. Embarassing each time...
>>> A normal VMS session only ever has one process that is reused over
>>> and over again to run programs (unless you choose to start a subprocess
>>> for some reason.)
>>
>> Well, not really true. Every time you start a program, it gets a new
>> process ID, with new resources allocated in the kernel for it. Just that
>> P1 space is retained between them, unless I remember wrong.
>>
>
> That is completely and totally utterly wrong. However, if you really
> believe that (instead of you just doing a David by trolling by making
> false statements :-)) it also explains your confusion because VMS works
> so differently to what you are clearly used to.
No. I did believe that. I had some recollection that the PIDs were
allocated each time a program was started. Partly (again) coming from
RSX. Structures like PCB, TCB, task headers and so on are setup when a
program is started, and thus every time a program starts, you have a new
context in this sense.
But this is also a place where RSX and VMS differs the most, since in
RSX, the "shell" is in a sense even weirder than VMS, or any other OS I
know of.
But the end result is that every time a program is started, it has it's
own process id. That DCL under VMS actually will be starting everything
as a part of its own process is really weird, and it makes me also
wonder how things like spawning another program from a program under VMS
works, since it would need to create a new DCL instance then. On the
other hand, I now recollect that VMS don't have spawn as a system call
like RSX do.
But that certainly explains why creating a new process under VMS is even
heaver.
So yeah, I certainly seem to have been totally lost on this detail.
> The PID does _not_ belong to the program. It belongs to the process itself.
That was something I thought I remembered being different.
> At many times during the lifecycle of a typical VMS process, there will not
> even _be_ a user-mode program loaded into the process P0 address space.
That on the other hand isn't any strange to me, and does not necessarily
follow, or lead to the topics of the PID itself.
> In Linux, there is no such thing as an executing process without a
> user-mode program, regardless of whether that user-mode program is
> a shell, a user's application program, or something else. Also, every
> time the shell runs a new program, the program is run in a new and
> different process.
Yes.
> OTOH, in VMS, having a process you can interact with, but without
> having any user-mode P0 program loaded, is a perfectly normal thing.
Yes.
> When you ask DCL to run a program, _it_ maps the requested program
> into the P0 address space, sets it up, and then calls it to start
> execution of the user program.
But you say that not only that - it also uses the context of DCL. So
that from an accounting point of view, it's still the same process. What
about process quotas like runtime limits? Do DCL reset these, and DCL
itself is excluded from such? And accounting. When a program runs and is
finished, you get accounting information on how much cpu time was used,
memory, and all kind of stuff. Is DCL then doing that accounting
processing, and not the kernel? A process calling something like exit
will not terminate the process, but just jump back to DCL?
> When the user program exits, the user-mode pages used by that program,
> but _only_ those user-mode pages, are removed from the process address
> space, and control returns to DCL to await your next command.
Does DCL do that, or the kernel?
> There is no "new process ID, with new resources allocated in the kernel
> for it". It's the same physical process that gets used over and over
> again during the user's session to run different user-mode programs.
That was something I had forgotten/misunderstood/never realized.
> Running a user program on VMS from DCL is much more like DCL doing
> a dlopen() on the user program into P0 space and then doing a call
> to it, instead of the Linux/Unix approach of creating a whole new
> fresh process for each program the shell wants to run.
I can understand that bit. But I then wonder about the whole winding
down of the running of the program, as commented above.
> _Now_ do you understand why I am describing the VMS approach in the
> way I am ?
In part, yes. I still do not consider DCL to be part of userspace, user
programs or anything like that. It's an OS component, and have rights
and privileges which means it can do anything really. Your ranting about
security issues around that topic is still nonsense to me. But VMS is
certainly doing things a bit odd in some ways that I think are unwise here.
> For the record, I prefer the Unix approach, but I am trying to make
> you understand how the VMS approach actually works, not how you think
> it works.
And as I observed, this is hardly Unix specific. The fact that VMS do
things odd is just a bit more surprising to me, since I know how RSX
works, upon which so much of VMS is based, but this is one place where
RSX works more like Unix. So how VMS diverged there is an interesting
topic in my head.
(Not that RSX actually is like Unix, RSX is actually sortof different in
another way, but in the perspective of how VMS works, RSX isn't close here.)
Johnny