Académique Documents
Professionnel Documents
Culture Documents
Objectives
Define processes as used by the Linux kernel View and control running processes using command-line and graphical utilities Understand and manage how memory is used by Linux processes Schedule delayed execution of processes
Defining Processes
Should be familiar with process definition to better understand
How Linux operates How to manage its resources
Creating Processes
Kernel starts process called init
When Linux first started Every process running on Linux is descendant of init process
Process id (PID)
Unique number identifying process within Linux kernel
Exit
When process ends Information about process that kernel was maintaining discarded Resources that kernel had allocated to process released
Process States
Running Sleeping Stopped Zombie
Swap Space
Used when system runs out of RAM for currently running programs Separate hard disk partition called swap partition Also called virtual memory Acts like extension of systems RAM Swapped-out process cannot run until swapped again
10
11
12
jobs command
Lists all jobs or processes running as descendants of current shell
Also called child processes
13
fg command
Place suspended job in foreground Must specify:
Job number using % Or PID
14
Alt+F2
Access second virtual console
The Complete Guide to Linux System Administration 15
ps command
u option shows how each process is using system f option
Displays relationship between different processes Shows which processes start other processes Processes presented in tree diagram
The Complete Guide to Linux System Administration 17
%CPU field
Compares amount of CPU time used by process with total time elapsed since previous computation of %CPU field Form of percentage
The Complete Guide to Linux System Administration 18
%WCPU field
Weighted to show 30-second average of percentage of CPU time used by process Helpful for showing overall usage pattern
19
21
22
Controlling Processes
kill command
Controls any process Sends signals to processes -l option views all signals Examples:
kill -9 1482 kill -SIGTERM 1482
23
SIGTERM signal
Number 15 Requests that program end Almost all programs respond
The Complete Guide to Linux System Administration 24
25
Each process assigned priority determines how much CPU time granted to process Normally all processes have same priority
The Complete Guide to Linux System Administration 26
27
renice command
renice +10 1776
28
29
Gkrellm
View system status information on desktop continuously
30
Add second microprocessor Move some tasks to different computer Add memory
The Complete Guide to Linux System Administration 31
Managing Memory
Other key system resources
Physical memory (RAM) Virtual memory (swap space)
32
ldd command
Lists all libraries that program requires
The Complete Guide to Linux System Administration 33
Kernel keeps track of which pages of memory are moved to swap space
34
Buffer
Memory used by application for data storage
Several fields of ps command output also provide information about memory usage
35
36
Scheduling Processes
at command
Define one or more commands to be executed at some future time Command relies on background process called atd
crontab command
Define one or more commands to be executed repeatedly at intervals that you designate Relies on background process called crond
The Complete Guide to Linux System Administration 37
Or listed in file
at -f <filename> <time specification>
atd daemon checks once per minute for any jobs that scheduled using at command Output of commands e-mailed to user
38
39
batch command
Similar to at Runs commands when system load average drops below 0.8
40
43
44
45
Summary
Linux is a multiprocessing operating system New processes are created by forking existing process ps command displays many different fields of information about each process kill command sends signals to processes or to Linux kernel to end process
46
Summary (continued)
Each process in Linux assigned priority
Called nice level
top command lists processes according to how much CPU time they are using free and vmstat commands display information about RAM and virtual memory usage
47
Summary (continued)
at command schedules task for execution by atd at future point batch command accepts tasks for future execution without fixed time crontab command schedules tasks to be executed on regular basis
48