Motivation-ApplicationSide Why not create a process for each task?-Processcreationis: Heavy-weighted·Resourceintensive Still remember what kinds of data are included in aprocess...- Text, data, stack, heap in user-space memory-PcBinkernel-spacememoryMany of the data can be shared between multipletasks within an application6
Motivation – Application Side • Why not create a process for each task? – Process creation is • Heavy-weighted • Resource intensive • Still remember what kinds of data are included in a process. – Text, data, stack, heap in user-space memory – PCB in kernel-space memory • Many of the data can be shared between multiple tasks within an application 6
Motivation-SystemSide? Modern computers usually contain multicores- But, each processor can run only one process at a time- CPU is not fully utilized· How to improve the efficiency?-Assign one task to each core- Real parallelism (not just concurrency with interleavingonsingle-coresystem)7
Motivation – System Side • Modern computers usually contain multicores – But, each processor can run only one process at a time – CPU is not fully utilized • How to improve the efficiency? – Assign one task to each core – Real parallelism (not just concurrency with interleaving on single-core system) 7
Concurrencyvs.ParallelismConcurrent execution on single-core system:T1T2T3T4T1T3T4T2T1single coretimeParallel execution on a multi-core system:T1T3T3T1T1core1T4T4T2T2T2core2time8
Concurrency vs. Parallelism 8 Concurrent execution on single-core system: Parallel execution on a multi-core system:
Multi-threading- Motivation- Thread Concept
9 Multi-threading - Motivation - Thread Concept
High-level ldeafilesdatafilescodedatacodestackregistersregistersregistersregistersstackstackstackthreadthreadmultithreadedprocesssingle-threadedprocess10
High-level Idea 10