Download presentation
Presentation is loading. Please wait.
1
Processes & Daemons Chapter IV / Part III
2
Commands Internal commands: alias, cd, echo, pwd, time External commands, code is in a file: grep, ls, more Command (usually) is a file Binary or shell script ls is actually /bin/ls command files set to executable Can use relative pathname if in PATH echo $PATH add to path export PATH=$PATH:~/bin
3
Processes Processes lie at the heart of all Unix/Linux OS Very crucial to understanding the operating system Process - an independently running program has own set of resources, such as CPU time, memory, hard disk space Linux is a multiprocessing OS multiple processes running at the same time Process scheduler: part of kernel processes can communicate
4
Processes Resources managed by kernel everything else is a process shell processes & daemons forking ps top
5
/proc Useful for analyzing processes and hardware Numbered directory for running process Example cmdline : the parent command line status : current status cwd : current working directory Hardware info meminfo ioports
6
Forking Example
7
Process states Linux Processes state diagrams
8
Background Processes started with an ‘&’ jobs fg bring into foreground bg resumes execution pgrep -f Sequential process execution cmd1; cmd2; cmd3 Parallel execution cmd1& cmd2 & cmd3
9
Process creation By forking what happens when command wc input.txt is executed shell searches for wc and input.txt checks wc for permission calls fork to create a child shell child shell calls exec to become wc wc executes control is returned to shell
10
Process hierarchy System starts with GRUB starts kernel init - PID 1 (started by swapper (PID 0)) initialized background daemons initializes and mounts root filesystem starts getty on every terminal for login process login success: forks a shell shell continues till failure: goes back to getty
11
Boot process
12
Process hierarchy
13
Processes only init and swapper are permanent ps -e f or pstree shows hierarchical view of processes pstree is more compact view ulimit
14
Daemons Background system processes monitor hardware networking tasks schedule tasks usually end with a d lpd, ftpd, httpd, sshd,.... directly owned by init process usually launched at boot time
15
Runlevels Runlevel: current system state 0 : system at halt 6: reboot 1: single user mode 2 - 5: different stages of system execution runlevel; who -r init manages the runlevel /etc/inittab lists which processes are started when
16
inittab /etc/inittab format id:runlevel:action:process specifying default level id:3:initdefault:
17
rc.d directories Under /etc/ each corresponds to a runlevel Hold scripts (programs) for startup and kill links to /etc/init.d S* - starting K* - killing explicitly start or stop a service
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.