Skip to content

cs-pub-ro/os-lecture-06-compute-part-1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 

Repository files navigation

Compute (part 1)

0. Pitch

  • demo: typical processes - from different executables - need for multi-process environment
  • demo: video decoding with ffmpeg using libx264 - uses multithreading - parallel runs

1. Running an Application

  • 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

2. Process Address Space

  • process address space layout
  • diagram: initializing / populating process address space (loading and initializing)
  • diagram: roles of each zone

3. Process Thread(s)

  • 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

4. Process Operations

  • 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

5. Thread Operations

  • create thread, wait for thread
    • from function
  • demo: create and join

6. fork() and exec()

  • 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()

Conclusion and Takeaways

  • 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

About

Operating Systems: Compute: Part1

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published