Intro to Processes
Notes
- This is chapter 3 of the book.
- Jobs, processes, threads
- Before multitasking a program to run was called a job
- Eventually we renamed them to be processes
- Finally we have threads, or lightweight processes
- We will look more at threads in the future
- These terms are not equivalent, but ...
- A process has a state
- Roughly these are
- New, starting, being created
- Running: currently in the CPU executing]
- Ready: has everything it needs, but is not in the CPU
- Waiting: is blocked while a request is being processed (I/O)
- Exiting:
- In a linux you can see the processes with
- top
- The state column: R- running, S-Sleeping, D-Deep Sleep, - T stopped, Z -ZOMBIE!, I -idle, R
- ps -ef
- ps -eo pid,user,stat,comm
- The Stat field
First Letter Meaning D uninterruptible sleep (usually IO) I Idle kernel thread R running or runnable (on run queue) S interruptible sleep (waiting for an event to complete) T stopped by job control signal t stopped by debugger during the tracing W paging (not valid since the 2.6.xx kernel) X dead (should never be seen) Z defunct ("zombie") process, terminated but not reaped by its parent Second Letter Meaning < high-priority (not nice to other users) N low-priority (nice to other users) L has pages locked into memory (for real-time and custom IO) s is a session leader l is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) + is in the foreground process group
- The Stat field
- top
- Roughly these are
- In linux, this is called
task_struct- /include/linux/sched.h line 819 - 1688
- It contains
- process and group ids
- state
- name
- exit information
- parents and children
- Priority information and other scheduling information
- Memory information
- File System information
- Signals and other communications information
- Thread information
- And a bunch of other stuff.