The Unix Heritage Society mailing list
 help / color / mirror / Atom feed
* [TUHS] single user mode in v5 & v6
@ 2015-01-09 18:06 Noel Chiappa
  2015-01-09 18:59 ` Dave Horsfall
  0 siblings, 1 reply; 13+ messages in thread
From: Noel Chiappa @ 2015-01-09 18:06 UTC (permalink / raw)


    > From: Noel Chiappa

    > For some reason, the code for /etc/init .. bashes the command line so
    > it just has '-' in it, so it looks just like a shell.

BTW, that may be accidental, not a deliberate choice - e.g. someone copied
another line of code which exec'd a shell, and didn't change the second arg.

    > I fixed my copy so it says "/etc/init", or something like that. ... I
    > can upload the 'fixed' code tomorrow.

The change is pretty minor: in this piece of code:

	case reboot:
		termall();
		execl(init, minus, 0);
		reset();

just change the execl() line to say:

		execl(init, init, 0);


    >> I'm not sure if unix of the v6 or v5 era was designed to go from multi
    >> user to single user mode and then back again.

    > I seem to recall there's some issue, something like in some cases
    > there's an extra shell left running attached to the console

So the bug is that in going from single-user to multi-user, by using "kill -1
1" in single-user with the switch register set for multi-user, it doesn't
kill the running single-user shell on the console. The workaround to that bug
which I use is to set the CSWR and then ^D the running shell.

In general, the code in init.c isn't quite as clean/clear as would be optimal
(which is part of why I haven't tried to fix the above bug), but _in general_
it does support going back and forth.


    > From: Ronald Natalie

    > our init checked the switch register to determine whether to bring up
    > single or multiuser

I think that's standard from Bell, actually.

    > I believe our system shutdown if you kill -1-1 (HUP to init).

The 'stock' behaviour is that when that happens, it checks the switch
register, and there are three options (the code is a little hard to follow,
but I'm pretty sure this is right):

- if it's set for single-user, it shuts down all the other children, and
brings up a console shell; when done, it does the next
- if it's set for 'reboot', it just shuts down all children, and restarts
the init process (presumably so one can switch to a new version of the init
without restarting the whole machine);
- if it's not set for either, it re-reads /etc/ttys, and for any lines which
have switched state in that file, it starts/kills the process listening to
that line (this allows one to add/drop lines dynamically).


    > From: Clem Cole

    > it's probably worth digging up the v6 version of fsck.

That's on that MIT V6 tape, too. Speaking of which, time to write the code to
grok the tape...

	Noel



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09 18:06 [TUHS] single user mode in v5 & v6 Noel Chiappa
@ 2015-01-09 18:59 ` Dave Horsfall
  0 siblings, 0 replies; 13+ messages in thread
From: Dave Horsfall @ 2015-01-09 18:59 UTC (permalink / raw)


On Fri, 9 Jan 2015, Noel Chiappa wrote:

>     > For some reason, the code for /etc/init .. bashes the command line 
>     > so it just has '-' in it, so it looks just like a shell.
> 
> BTW, that may be accidental, not a deliberate choice - e.g. someone 
> copied another line of code which exec'd a shell, and didn't change the 
> second arg.

I have a vague recollection of patching "ps" so that process 0 showed as 
"unix" or something, as otherwise it was just random rubbish.

>     > our init checked the switch register to determine whether to bring 
>     > up single or multiuser
> 
> I think that's standard from Bell, actually.

Yes.

-- 
Dave Horsfall DTM (VK2KFU)  "Bliss is a MacBook with a FreeBSD server."
http://www.horsfall.org/spam.html (and check the home page whilst you're there)



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09 20:57   ` Ronald Natalie
@ 2015-01-09 21:18     ` Clem Cole
  0 siblings, 0 replies; 13+ messages in thread
From: Clem Cole @ 2015-01-09 21:18 UTC (permalink / raw)


On Fri, Jan 9, 2015 at 3:57 PM, Ronald Natalie <ron at ronnatalie.com> wrote:

> The symbol table was commonly used, but that was not so good if you didn't
> boot from /unix.
>
> IIRC that we stuffed the pathname that we booted with somewhere, so that
ps could find it.   All of this is very hazy now, too many different UNIX
systems and different hacks over the years ;-)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20150109/bca03ce0/attachment.html>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09 20:54 ` Clem Cole
@ 2015-01-09 20:57   ` Ronald Natalie
  2015-01-09 21:18     ` Clem Cole
  0 siblings, 1 reply; 13+ messages in thread
From: Ronald Natalie @ 2015-01-09 20:57 UTC (permalink / raw)


The symbol table was commonly used, but that was not so good if you didn't boot from /unix.




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09 18:38 Noel Chiappa
@ 2015-01-09 20:54 ` Clem Cole
  2015-01-09 20:57   ` Ronald Natalie
  0 siblings, 1 reply; 13+ messages in thread
From: Clem Cole @ 2015-01-09 20:54 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 850 bytes --]

On Fri, Jan 9, 2015 at 1:38 PM, Noel Chiappa <jnc at mercury.lcs.mit.edu>
wrote:

>
> Not just the command field!
>
​right...
​


>
> The real problem was that all the parameters (e.g. NPROC) were not stored
> in
> the kernel anywhere, so if you wanted to have one copy of the 'ps' binary
> which would work on two different machines (but which were running the same
> version of the kernel)... rotsa ruck.
>
​Yup, I remember that ...​





>
>
>
> I've hacked my copy of 'ps' to grovel around in the system's symbol table,
> and print 'wchan' symbolically.

​right - that look pretty much what it looked like on our systems.  Great
minds run on the same channel.

Clem​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20150109/bb9c8767/attachment.html>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
@ 2015-01-09 18:38 Noel Chiappa
  2015-01-09 20:54 ` Clem Cole
  0 siblings, 1 reply; 13+ messages in thread
From: Noel Chiappa @ 2015-01-09 18:38 UTC (permalink / raw)


    > From: Clem Cole

    > ps "knew" about some kernel data structures and had to compiled with
    > the same sources that your kernel used if you want all the command
    > field in particular to look reasonable.

Not just the command field!

The real problem was that all the parameters (e.g. NPROC) were not stored in
the kernel anywhere, so if you wanted to have one copy of the 'ps' binary
which would work on two different machines (but which were running the same
version of the kernel)... rotsa ruck.

I have hacked my V6 to include lines like:

  int     ninode  NINODE;
  int     nfile   NFILE;
  int     nproc   NPROC;

etc so 'ps' can just read those variables to find the table sizes in the
running kernel. (Obviously if you modify a table format, then you're SOL.)


    > From: Ronald Natalie

    > The user structure of the currently running process is the only one
    > that is guaranteed to be in memory ... Any processes that were swapped
    > you could read the user structure so things that were stored there were
    > often unavailable (particularly the command name). 

Well, 'ps' (even the V6 stock version) was actually prepared to poke around
on the swap device to look at the images of swapped-out processes. And the
command name didn't come from the U area (it wasn't saved there in stock V6),
'ps' actually had to look on the top of the user stack (which is why it
wasn't guaranteed to be accurate - the user process could smash that).


    > From: Clem cole

    > IIRC we had a table of sleep addresses so that ps could print the
    > actual thing you were waiting for not just an address. 

I've hacked my copy of 'ps' to grovel around in the system's symbol table,
and print 'wchan' symbolically. E.g. here's some of the output of 'ps' on
my system:

 TTY  F  S UID   PID  PPID PRI NIC CPU TIM ADDR  SZ  TXT   WCHAN       COMMAND
 ?:   SL S   0     0     0-100   0  -1 127 1676   16    runout         <swapper>
 ?:    L W   0     1     0  40   0   0 127 1774   43  0 proc+26        /etc/init
 ?:    L W   0    11     1  90   0   0 127 2405   37    tout           /etc/update
 8:    L W   0    12     1  10   0   0 127 2772   72  2 kl11           -
 a:    L W   0    13     1  40   0   0 127 3122   72  2 proc+102       -
 a:    L R   0    22    13 100   0  10   0 3422  138  3                ps axl
 b:    L W   0    14     1  10   0   0 127 2120   41  1 dz11+40        - 4

It's pretty easy to interpret this to see what each process is waiting for.

	Noel



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09 14:44   ` Ronald Natalie
@ 2015-01-09 16:52     ` Clem cole
  0 siblings, 0 replies; 13+ messages in thread
From: Clem cole @ 2015-01-09 16:52 UTC (permalink / raw)


Right.  We did some similar stuff at CMU.  One other hack we had was science compiled ps with the kernel IIRC we had a table of sleep addresses so that ps could print the actual thing you were waiting for not just an address.  I think that was a Dan Klein hack. 


Yeah the ^T hack was implemented a number of times.  Masscomp is the only product kernel that I knew supported it.  I did miss it for a long time 

Clem

Sent from my iPhone

> On Jan 9, 2015, at 9:44 AM, Ronald Natalie <ron at ronnatalie.com> wrote:
> 
> If I recall, PS read /dev/kmem to get the proc structure which was a table of all the active processes.
> The user structure of the currently running process is the only one that is guaranteed to be in memory (the others could be paged out)
> and at least on our system was always located at 0140000.    Any processes that were swapped you could read the user structure
> so things that were stored there were often unavailable (particularly the command name).   Yeah, so ps had intimate knowledge of the
> layout of the kernel user and proc structures.
> 
> We moved a short version of the command name into the proc structure for reason.   We added a new TTY special character ^T
> (borrowed that from the KA-10 guys) to do a brief listing of the processes controlled by the current terminal from within the kernel. (Mike Muuss did this while he was playing with scheduler hacking).
> 
>> 
>> 
>> Also remember for early UNIX, ps "knew" about some kernel data structures and had to compiled with the same sources that your kernel used if you want all the command field in particular to look reasonable.
>> 
>> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20150109/d67079f7/attachment.html>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09 14:36 ` Clem Cole
@ 2015-01-09 14:44   ` Ronald Natalie
  2015-01-09 16:52     ` Clem cole
  0 siblings, 1 reply; 13+ messages in thread
From: Ronald Natalie @ 2015-01-09 14:44 UTC (permalink / raw)


If I recall, PS read /dev/kmem to get the proc structure which was a table of all the active processes.
The user structure of the currently running process is the only one that is guaranteed to be in memory (the others could be paged out)
and at least on our system was always located at 0140000.    Any processes that were swapped you could read the user structure
so things that were stored there were often unavailable (particularly the command name).   Yeah, so ps had intimate knowledge of the
layout of the kernel user and proc structures.

We moved a short version of the command name into the proc structure for reason.   We added a new TTY special character ^T
(borrowed that from the KA-10 guys) to do a brief listing of the processes controlled by the current terminal from within the kernel. (Mike Muuss did this while he was playing with scheduler hacking).

> 
> 
> Also remember for early UNIX, ps "knew" about some kernel data structures and had to compiled with the same sources that your kernel used if you want all the command field in particular to look reasonable.
> 
> 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20150109/4fccbb2b/attachment.html>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09 14:23 ` Ronald Natalie
@ 2015-01-09 14:36   ` Clem Cole
  0 siblings, 0 replies; 13+ messages in thread
From: Clem Cole @ 2015-01-09 14:36 UTC (permalink / raw)


On Fri, Jan 9, 2015 at 9:23 AM, Ronald Natalie <ron at ronnatalie.com> wrote:

> If I recall, our V6 system would go from singe user to multiuser when you
> logged out of the single user shell (our init checked the switch register
> to determine whether to bring up single or multiuser).


That is the behavior I remember, also.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20150109/cc60ee14/attachment.html>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09  6:18 Noel Chiappa
  2015-01-09 14:23 ` Ronald Natalie
@ 2015-01-09 14:36 ` Clem Cole
  2015-01-09 14:44   ` Ronald Natalie
  1 sibling, 1 reply; 13+ messages in thread
From: Clem Cole @ 2015-01-09 14:36 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

On Fri, Jan 9, 2015 at 1:18 AM, Noel Chiappa <jnc at mercury.lcs.mit.edu>
wrote:

> Just out of curiousity, why don't you set the SR before you boot the
> machine?
> That way it'll come up single user, and you can icheck/dcheck before you go
> to multi-user mode. I prefer doing it that way, there's as little as
> possible
> going on, in case the disk is slightly 'confused', so less chance any
> bit-rot
> will spread...
>

​Right and it's probably worth digging up the v6 version of fsck.  I had it
on tape but I worry that it might be 800 bpi which I have lost the ability
to read.  I need to find a working TS08.

Also remember for early UNIX, ps "knew" about some kernel data structures
and had to compiled with the same sources that your kernel used if you want
all the command field in particular to look reasonable.

I've forgotten when that got fixed, my memory is that V7 still had vestiges
of that issue i.e. it was not until post 4.1BSD that got ps got more
independant.   That said, until V8 and /proc that user mode utilities like
that got really cleaned up.

Clem
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://minnie.tuhs.org/pipermail/tuhs/attachments/20150109/4bd6c022/attachment.html>


^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
  2015-01-09  6:18 Noel Chiappa
@ 2015-01-09 14:23 ` Ronald Natalie
  2015-01-09 14:36   ` Clem Cole
  2015-01-09 14:36 ` Clem Cole
  1 sibling, 1 reply; 13+ messages in thread
From: Ronald Natalie @ 2015-01-09 14:23 UTC (permalink / raw)


If I recall, our V6 system would go from singe user to multiuser when you logged out of the single user shell (our init checked the switch register to determine whether to bring up single or multiuser).    I believe our system shutdown if you kill -1-1 (HUP to init).   V7 would revert to single user at that point.


I think the init 
> On Jan 9, 2015, at 1:18 AM, Noel Chiappa <jnc at mercury.lcs.mit.edu> wrote:
> 
>> From: Mark Longridge <cubexyz at gmail.com>
> 
>> I've finally managed to get Unix v5 and v6 to go into single user mode
>> while running under simh.
>> ...
>> dep system sr 173030 (simh command)
> 
> Just out of curiousity, why don't you set the SR before you boot the machine?
> That way it'll come up single user, and you can icheck/dcheck before you go
> to multi-user mode. I prefer doing it that way, there's as little as possible
> going on, in case the disk is slightly 'confused', so less chance any bit-rot
> will spread...
> 
>> Now I'm in muti user mode .. but then if I do a "ps -alx" I get:
>> 
>> TTY F S UID   PID PRI ADDR  SZ  WCHAN COMMAND
>> ?:  3 S   0     0-100 1227   2   5676 ????
>> ?:  1 W   0     1  40 1324   6   5740 -
> 
>> The ps command doesn't show the /etc/init process explicitly, although
>> I'm pretty sure it is running.
> 
> No, it's there: the second line (PID 1). For some reason, the code for
> /etc/init (in V6 at least, I don't know anything about V5) bashes the command
> line so it just has '-' in it, so it looks just like a shell.
> 
> I fixed my copy so it says "/etc/init", or something like that. The machine
> my source is on is powered down at the moment; if you want, I can upload the
> 'fixed' code tomorrow.
> 
>> I'm not sure if unix of the v6 or v5 era was designed to go from multi
>> user to single user mode and then back again.
> 
> I seem to recall there's some issue, something like in some cases there's an
> extra shell left running attached to the console, but I don't recall the
> details (too lazy to look for the note I made about the bug; I can look it up
> if you really want to know).
> 
>> Would it be safer to just go to single user and then shut it down?
> 
> I don't usually bother; I just log out all the shells except the one on the
> console, so the machine is basically idle; then do a 'sync', and shortly
> after than completes, I just halt the machine.
> 
> 	Noel
> _______________________________________________
> TUHS mailing list
> TUHS at minnie.tuhs.org
> https://minnie.tuhs.org/mailman/listinfo/tuhs




^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
@ 2015-01-09  6:18 Noel Chiappa
  2015-01-09 14:23 ` Ronald Natalie
  2015-01-09 14:36 ` Clem Cole
  0 siblings, 2 replies; 13+ messages in thread
From: Noel Chiappa @ 2015-01-09  6:18 UTC (permalink / raw)


    > From: Mark Longridge <cubexyz at gmail.com>

    > I've finally managed to get Unix v5 and v6 to go into single user mode
    > while running under simh.
    > ...
    > dep system sr 173030 (simh command)

Just out of curiousity, why don't you set the SR before you boot the machine?
That way it'll come up single user, and you can icheck/dcheck before you go
to multi-user mode. I prefer doing it that way, there's as little as possible
going on, in case the disk is slightly 'confused', so less chance any bit-rot
will spread...

    > Now I'm in muti user mode .. but then if I do a "ps -alx" I get:
    >
    > TTY F S UID   PID PRI ADDR  SZ  WCHAN COMMAND
    > ?:  3 S   0     0-100 1227   2   5676 ????
    > ?:  1 W   0     1  40 1324   6   5740 -

    > The ps command doesn't show the /etc/init process explicitly, although
    > I'm pretty sure it is running.

No, it's there: the second line (PID 1). For some reason, the code for
/etc/init (in V6 at least, I don't know anything about V5) bashes the command
line so it just has '-' in it, so it looks just like a shell.

I fixed my copy so it says "/etc/init", or something like that. The machine
my source is on is powered down at the moment; if you want, I can upload the
'fixed' code tomorrow.

    > I'm not sure if unix of the v6 or v5 era was designed to go from multi
    > user to single user mode and then back again.

I seem to recall there's some issue, something like in some cases there's an
extra shell left running attached to the console, but I don't recall the
details (too lazy to look for the note I made about the bug; I can look it up
if you really want to know).

    > Would it be safer to just go to single user and then shut it down?

I don't usually bother; I just log out all the shells except the one on the
console, so the machine is basically idle; then do a 'sync', and shortly
after than completes, I just halt the machine.

	Noel



^ permalink raw reply	[flat|nested] 13+ messages in thread

* [TUHS] single user mode in v5 & v6
@ 2015-01-09  4:59 Mark Longridge
  0 siblings, 0 replies; 13+ messages in thread
From: Mark Longridge @ 2015-01-09  4:59 UTC (permalink / raw)


Ok, I've finally managed to get Unix v5 and v6 to go into single user
mode while running under simh.

I boot up unix as normal, that is to say in multi-user mode.
Then a ctrl-e and

dep system sr 173030 (simh command)

then c to continue execution of the operating system and finally "kill -1 1".

This gets me from multi user mode to single user mode. I can also go
back to multi user mode with:

ctrl-e and dep system sr 000000

then once again c to continue execution of the operating system and "kill -1 1".

Now I'm in muti user mode, and I can telnet in as another user so it
seems to be working but then if I do a "ps -alx" I get:

TTY F S UID   PID PRI ADDR  SZ  WCHAN COMMAND
?:  3 S   0     0-100 1227   2   5676 ????
?:  1 W   0     1  40 1324   6   5740 -
8:  1 W   0    51  40 2456  19   5766 -
?:  1 W   0    55  10 1377   6  42066 -
?:  1 W   0     5  90 1734   5   5440 /etc/update
?:  1 W   0    32  10 2001   6  42126 -
?:  1 W   0    33  10 2054   6  42166 -
?:  1 W   0    34  10 2127   6  42226 -
?:  1 W   0    35  10 2202   6  42266 -
?:  1 W   0    36  10 2255   6  42326 -
?:  1 W   0    37  10 2330   6  42366 -
?:  1 W   0    38  10 2403   6  42426 -
8:  1 R   0    59 104 1472  17        ps alx

The ps command doesn't show the /etc/init process explicitly, although
I'm pretty sure it is running. I'm not sure if unix of the v6 or v5
era was designed to go from multi user to single user mode and then
back again. Would it be safer to just go to single user and then shut
it down?

Mark



^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2015-01-09 21:18 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-09 18:06 [TUHS] single user mode in v5 & v6 Noel Chiappa
2015-01-09 18:59 ` Dave Horsfall
  -- strict thread matches above, loose matches on Subject: below --
2015-01-09 18:38 Noel Chiappa
2015-01-09 20:54 ` Clem Cole
2015-01-09 20:57   ` Ronald Natalie
2015-01-09 21:18     ` Clem Cole
2015-01-09  6:18 Noel Chiappa
2015-01-09 14:23 ` Ronald Natalie
2015-01-09 14:36   ` Clem Cole
2015-01-09 14:36 ` Clem Cole
2015-01-09 14:44   ` Ronald Natalie
2015-01-09 16:52     ` Clem cole
2015-01-09  4:59 Mark Longridge

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).