- demo: typical processes - from different executables - need for multi-process environment
- demo: video decoding with
ffmpegusinglibx264- uses multithreading - parallel runs
- applications run as processes
- diagram: a process is a (virtual) address space and an execution context
- the execution context is called a thread - can be multiple - main thread + others
- demo: list all processes and list all threads in the system
- process address space layout
- diagram: initializing / populating process address space (loading and initializing)
- diagram: roles of each zone
- execution context: what do I need to run?
- in summary, an IP and a stack pointer
- a stack provides an execution flow (return path) and local context (local variables, function parameters)
- diagram: IP points to the same zone, SP to a different thread per stack
- threads share process address space
- each thread has their own stack
- main thread
- demo: create a thread, see creation of a new stack
- demo: print IP and SP of each thread
- create process, kill process, wait process
- from executable
- diagram: create process: create address space, load address space, create thread, start thread
- demo: posix_spawn()
- process hierarchy
- demo: waiting for a process
- zombie processes, orphan processes
- create thread, wait for thread
- from function
- demo: create and join
- diagram: fork() and exec() steps
- fork() only used for multiprocessing - alternative to multithreading
- demo: fork() + exec() vs posix_spawn()
- demo: strace for fork(), exec(), posix_spawn() and pthread_create()
- processes are the core component to run applications
- a process is an address space and one or more threads (execution contexts)
- threads share process address space (except for the stack)
- processes form a hierarchy, a process is created by another process
- processes wait for child processes