1 / 17

Processes & Daemons

Processes & Daemons. Chapter IV / Part III. 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

gene
Download Presentation

Processes & Daemons

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  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 <process-name> • 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 <Ctrl-D> • 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

More Related