Abstract


Benefits


Fast to Create/Destroy

Makes Programming Easier

Better Responsiveness

Powerpoint with Multiple Threads

An implementation of Multi-threading

  1. One thread can be used to receive inputs from users
  2. One thread can be used to format the slides
  3. One thread can be used to save the slides automatically on a regular interval

Benefits over Process

  1. Lighter to create and destroy compared to Process (进程), because it doesn’t require System Call (系统调用) to the underlying OS
  2. Share memory among themselves, avoid Memory Page Shifting which is expensive

Cons


No protection among threads

  • One thread can bring down the entire Process (进程)
  • One thread can read, write, or even wipe out another thread’s stack

Forking

  • Should we copy over all the threads or just a single one?

Interrupt Handling

Terminologies


Blocking

  • Thread doesn’t do anything while waiting for IO Operations or Network Operations etc

Non-blocking

  • Thread carries out other tasks if the current tasks require it to wait for IO Operations or Network Operations etc
  • Goes back to the current task when the waiting ends - Call back
  • However, it still blocks when the task is CPU Bounded

Thread Table