Skip to content

Instantly share code, notes, and snippets.

@yalab
Created November 20, 2017 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yalab/4182869777f6fcde05fcefeacf16723f to your computer and use it in GitHub Desktop.
Save yalab/4182869777f6fcde05fcefeacf16723f to your computer and use it in GitHub Desktop.
LinuxKernel勉強会2017-11.md

プロセス

プロセスってどうやって起動するのか調べる

linux kernel process invoke で検索すると http://www.tldp.org/LDP/tlk/kernel/processes.html

Linux の process とは task_struct 構造体の事で、task vector に 512 個まで格納される

process と task の違い?

include/linux/sched.h に task_struct の定義がある(597行もある)

task と process に違いは無い http://www.tldp.org/LDP/tlk/kernel/processes.html 4.1 Linux Process より

Process (task_struct) にあるもの

state

  • Running
  • Waiting
  • Stopped
  • Zombie

schedule infomation

identifier

process の発生

全ての親 process (pid 1) は /etc/init, /bin/init, /sbin/init (grub のブートパラメーターで変えられる) で ubuntu だと /lib/systemd/systemd へのシンボリックリンクになっていた。 /sbin/init でない場合はカーネルのぶーとぱらめーたーで変えられる

Ubuntu の pstree

systemd-+-accounts-daemon-+-{gdbus}
        |                 `-{gmain}
        |-2*[agetty]
        |-cron
        |-dbus-daemon
        |-dockerd-+-docker-containe-+-docker-containe-+-entrypoint.sh---fluentd+
        |         |                 |                 `-10*[{docker-containe}]
        |         |                 |-docker-containe-+-postgres---14*[postgres+
        |         |                 |                 `-8*[{docker-containe}]
        |         |                 |-docker-containe-+-redis-server---3*[{redi+
        |         |                 |                 `-10*[{docker-containe}]
        |         |                 |-docker-containe-+-bundle-+-{ruby-timer-th+
        |         |                 |                 |        `-27*[{util.rb:2+
        |         |                 |                 `-9*[{docker-containe}]
        |         |                 |-docker-containe-+-s6-svscan-+-2*[s6-super+
        |         |                 |                 |           |-s6-supervis+
        |         |                 |                 |           `-s6-supervis+
        |         |                 |                 `-9*[{docker-containe}]
        |         |                 |-docker-containe-+-ruby-+-{puma 001}
        |         |                 |                 |      |-{puma 002}
        |         |                 |                 |      |-{puma 003}
        |         |                 |                 |      |-{puma 004}
        |         |                 |                 |      |-{puma 005}
        |         |                 |                 |      |-{reactor.rb:152}
        |         |                 |                 |      |-{ruby-timer-thr}
        |         |                 |                 |      |-{server.rb:327}
        |         |                 |                 |      |-2*[{thread_pool.+
        |         |                 |                 |      `-{tmp_restart.rb*+
        |         |                 |                 `-9*[{docker-containe}]
        |         |                 `-17*[{docker-containe}]
        |         |-3*[docker-proxy---6*[{docker-proxy}]]
        |         |-docker-proxy---4*[{docker-proxy}]
        |         |-docker-proxy---5*[{docker-proxy}]
        |         `-25*[{dockerd}]
        |-irqbalance
        |-lvmetad
        |-rsyslogd-+-{in:imklog}
        |          |-{in:imuxsock}
        |          `-{rs:main Q:Reg}
        |-2*[ssh-agent]
        |-sshd-+-sshd---sshd---bash
        |      `-sshd---sshd---bash---sudo---su---bash---pstree
        |-2*[systemd---(sd-pam)]
        |-systemd-journal
        |-systemd-logind
        |-systemd-timesyn---{sd-resolve) S 1
        `-systemd-udevd

Docker での pstree

sh---pstree
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment