More About Processes
$ kill -9 ubshuttle # IPC: signals
-
Signals are a limited form of asynchronous communication between processes.
-
Processes can register a signal handler to run when a signal is received.
-
Users can send signals to processes owned by them; the super-user can send a signal to any process.
-
Processes can ignore most signals.
-
SIGKILL
is a notable exception; used for non-graceful termination. -
SIGTERM
is used for graceful shutdown.
-
We Will Return to IPC
-
return codes — we will discuss again when we learn about
wait()
and_exit()
.-
You will implement return codes for ASST2.
-
-
pipes — we will discuss again when we learn about
fork()
. -
signals — are difficult to use and implement and not something we will return to.
-
shared memory — we will discuss again when we learn about address spaces and virtual memory.
Processes v. Threads
-
Potentially confusing due to overlapping terminology—we can describe both a process and a thread as running.
-
Terminology can be helpful for remembering the distinction:
-
A computing process requires multiple resources: the CPU, memory, files, etc.
-
A thread of execution abstracts CPU state.
-
-
Processes contain threads; threads belong to a process.
-
Only one exception: the kernel may have threads of execution not associated with any user process
-
(Except the kernel process, which is a process, remember?)
-
-
A process is considered to be running when one or more of its threads are running.
-
Different operating systems use different terminology, but share common ideas.
Process Example: Firefox
-
Waiting for and processing interface events: mouse clicks, keyboard input, etc.
-
Redrawing the screen as necessary in response to user input, web page loading, etc.
-
Loading web pages—usually multiple parts in parallel to speed things up.
-
Firefox.exe: the executable code of Firefox itself.
-
Shared libraries for web page parsing, security, etc.
-
Stacks storing local variables for running threads.
-
A heap storing dynamically-allocated memory.
-
Configuration files.
-
Fonts.
Finding bash
-
ps aux
gives me all process, thengrep
for the one I’m after. -
…or, do it all in one shot using
pgrep
. -
…or, if I know it’s running in my current session a bare
ps
will do.
$ ps -Lf # thread information
-
UID
: user the process is running as. -
PID
: process ID. -
PPID
: parent process ID. -
PRI
: scheduling priority. -
SZ
: size of the core image of the process (kB). -
WCHAN
: if the process is not running, description of what it is waiting on. -
RSS
: total amount of resident memory is use by the process (kB). -
TIME
: measure of the amount of time that the process has spent running.
-
If
bash
had multiple threads running this view would show them, sobash
does not have multiple threads.