Thread Basics

Background

  • A running program is called a "process"
  • Each process has memory, list of open files, stack, program counter, etc...
  • Normally, a process executes statements in a single sequence of control-flow.

Process creation with fork(),system(), popen(), etc...

  • These commands create an entirely new process.
  • Child process runs independently of the parent.
  • Has own set of resources.
  • There is minimal sharing of information between parent and child.
  • Think about using the Unix shell.

Threads

  • A thread is kind of like a process (it's a sequence of control-flow).
  • Except that it exists entirely inside a process and shares resources.
  • A single process may have multiple threads of execution.
  • Useful when an application wants to perform many concurrent tasks on shared data.
  • Think about a browser (loading pages, animations, etc.)
<<< O'Reilly OSCON 2000, Advanced Python Programming, Slide 65
July 17, 2000, beazley@cs.uchicago.edu
>>>