YouTube placeholder

More About Processes

$ kill -9 ubshuttle # IPC: signals

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

Firefox has multiple threads. What are they doing?
  • 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 is using memory. For what?
  • 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.

Firefox has files open. Why?
  • Configuration files.

  • Fonts.

$ top # more process information

top

Process Example: bash

  • Let’s do this for real using standard Linux system utilities.

Finding bash

finding bash
  • ps aux gives me all process, then grep 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.

bash

process bash 3

$ ps -Lf # thread information

threads bash
What are:
  • 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.

threads bash
  • If bash had multiple threads running this view would show them, so bash does not have multiple threads.

bash

process bash 2

$ ps # process information

  • I wish we could see a process with multiple threads…​

$ ps -Lf # thread information

ps threads

$ pmap # memory mappings

pmap

Created 2/17/2017
Updated 8/17/2017
Commit 4eceaab // History // View
Built 2/5/2017 @ 19:00 EDT