:: Re: [DNG] Mini init script written …
Top Pagina
Delete this message
Reply to this message
Auteur: Joel Roth
Datum:  
Aan: dng
Onderwerp: Re: [DNG] Mini init script written in Perl boots.
Edward Bartolo wrote:
> PID 1 should fork only once to run the first script that loads the
> operating system. Once execution enters the infinite loop there is no
> way of it jumping to somewhere else.


I'm guessing the loop doesn't actually loop, as the
wait call just blocks.

> Therefore, only one child is
> forked. This child should terminate on as soon as the OS loading
> script terminates. On my system it behaves that way. Forking children
> indefinitely in absolutely NOT minimal and is highly undesired
> considering this should be minimal.
>
> I think it is a mistake to expect a few lines of code written in
> whatever language to outperform other init projects written in several
> thousand lines of code that are well debugged and mature. The place
> for these little scripts, as I see it, is for educational purposes and
> to power small computers like the Raspberry Pi, and maybe, to power
> the computer of enthusiast adolescent computer geeks who want to
> understand what goes on inside their operating system. Mind you, this
> is not a deep look inside what happens when an operating system boots,
> but it is better than having nothing, or worse of being presented
> with mystery where logic should prevail.


Agreed. That's a reason I'd wish my friends to be logging in
at the console and issuing startx, rather than having it
hidden away by the display manager. At they'd visit the
console once every power cycle! And if X hung, to be able to
issue Ctrl-Alt-Backspace (although the Alt-SysReq key
combination is still available.)


> Edward
>
> On 17/06/2016, Adam Borowski <kilobyte@???> wrote:
> > On Thu, Jun 16, 2016 at 10:47:42PM +0200, Irrwahn wrote:
> >> For the record: Should I ever find myself sitting at a
> >> machine running a Perl interpreter for PID1, I'd either
> >> immediately kill myself or drink the SystemD Kool-Aid
> >> by the gallon. (The net effect not being that different.)
> > On Thu, Jun 16, 2016 at 02:14:48PM -1000, Joel Roth wrote:
> >> I did a test with Memory::Usage, that reports the
> >> interpreter's virtual memory size as 22MB. Seems cheap
> >> to me.
> >
> > Yeah, we need to use an efficient language!
> >
> > .globl _start
> > .data
> > nopid1:    .ascii "No pid 1, no fun.\n"
> > command: .ascii "/sbin/osloader.sh"
> > norc: .ascii "Starting /sbin/osloader.sh failed!\n"
> > .text
> > _start:
> >     mov    $39, %rax    # getpid
> >     syscall
> >     cmp    $1, %rax
> >     je    pid1
> >     mov    $1, %rax    # write
> >     mov    $1, %rdi
> >     mov    $nopid1, %rsi
> >     mov    $18, %rdx
> >     syscall
> >     mov    $60, %rax    # _exit
> >     mov    $1, %rdi
> >     syscall
> > pid1:
> >     mov    $57, %rax    # fork
> >     syscall
> >     cmp    $0, %rax
> >     jne    child
> > parent:
> >     mov    $61, %rax    # wait4
> >     mov    $-1, %rdi
> >     xor    %rsi, %rsi
> >     xor    %rdx, %rdx
> >     syscall
> >     jmp    parent
> > child:
> >     mov    $59, %rax    # execve
> >     mov    $command, %rdi
> >     xor    %rsi, %rsi
> >     xor    %rdx, %rdx
> >     syscall
> >     mov    $1, %rax    # write
> >     mov    $1, %rdi
> >     mov    $norc, %rsi
> >     mov    $36, %rdx
> >     syscall
> >     mov    $60, %rax    # _exit
> >     mov    $1, %rdi
> >     syscall

> >
> > Hmmm... I think I'd go with Perl after all.
> >
> > Meow!
> > --
> > An imaginary friend squared is a real enemy.
> > _______________________________________________
> > Dng mailing list
> > Dng@???
> > https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng
> >
> _______________________________________________
> Dng mailing list
> Dng@???
> https://mailinglists.dyne.org/cgi-bin/mailman/listinfo/dng


--
Joel Roth