2015年12月9日 星期三

Operating System - CH4 Threads

Process creation is heavy-weight
Thread creation is light-weight

multi-thread優點
  • responsiveness
  • resource sharing
  • economy
  • scalability 同一個process內的不同thread可以平行在不同CPUs上執行

multicore programming challenge
  • divide activities
  • balance
  • data splitting
  • data dependency
  • test and debugging

User Threads
Kernel Threads: kernel 知道每條thread



Thread cancellation
  • asynchronous cancellation: terminate thread immediately
  • deferred cancellation: allow the target thread 定期確認自己是否應該cancel

Thread libraries: provide programmer with API to creating and managing threads

Java thread 
  • cread new class derive from Thread class
  • define a class that implements the Runnable interface

Signal Handling: signals are used to notify a process that a particular event has occured
Signal handler is used to process signals.

Thread Pools: create a number of threads in a pool where they await work.

upcalls
  • for many-to-many and two-level models
  • 溝通機制 from the kernel to the thread library.
  • allow app to maintain the correct number kernel threads.

clone() allow a child task to share the address space of the parent task.




沒有留言:

張貼留言