180 likes | 387 Views
Multiprocessor Scheduling (Advanced). Sangchul Kim (stdio@snu.ac.kr) School of Computer Science and Engineering Seoul National University. Outline. Introduction Background Issues of the multiprocessor system Multiprocessor Scheduling Linux Multiprocessor Schedulers Summary. Introduction.
E N D
Multiprocessor Scheduling (Advanced) Sangchul Kim (stdio@snu.ac.kr) School of Computer Science and Engineering Seoul National University
Outline Introduction Background Issues of the multiprocessor system Multiprocessor Scheduling Linux Multiprocessor Schedulers Summary
Introduction core core core core • Multiprocessor systems are increasingly common place. • Multiple CPU cores are packed onto a single chip. • The rise of the multicore processor is the source of the proliferation. • Thereare many difficulties. • A typical application only uses a single CPU. • Multiprocessor scheduling. • The center of the multiprocessor system is the use of hardware cache.
Background CPU Cache RAM Memory Main Storage • Properties of Cache • Small and fast memories that hold copies of popular data. • To help the processor run programs faster. • Strategies of Cache • Temporal locality • It is likely to be accessed again in the near future. • e.g. loop. • Spatial locality • It is likely to access data items near the currently accessed the items. • e.g. array.
Issues of the multiprocessor system CPU CPU Memory Cache Cache A A’ A A bus • Problem • Cache coherence • Multiprocessors with a shared single main memory. • Solution • Bus snooping • Either invalidate or update the data item.
Issues of the multiprocessor system (cont’) thread1 thread2 Problem thread1 thread2 • Example: Simple List Delete Code • Problem • Correctness • Shared queue being accessed on multiple CPUs concurrently. • Adding or removing elements from the queue concurrently will not work as expected. • Solution • Mutual exclusion (locking)
Issues of the multiprocessor system (cont’) CPU CPU Px Px TLBx Memory Cache Cache DataX bus • Cache Affinity • Keep a process on the same CPU if at all possible.
Multiprocessor Scheduling A B C D E Queue NULL CPU: CPU: migration • Single queue multiprocessor scheduling (SQMS) • Simply reuse the basic framework for single processor scheduling. • Advantage: simplicity. • Disadvantage : scalability and cache affinity. • To ensure the correctness, locking is used. • Implementing the migration scheme, it can be complex.
Multiprocessor Scheduling (cont’) A C B D Queue2 Queue1 CPU: • Multi-queue multiprocessor scheduling (MQMS) • The basic scheduling framework consists of multiple scheduling queues. • Each queue will likely follow a particular scheduling discipline. • Advantage: more scalable, cache affinity. • Disadvantage: load imbalance.
Multiprocessor Scheduling (cont’) A B D Queue2 Queue1 CPU: B D Queue2 Queue1 CPU: • Multi-queue multiprocessor scheduling (MQMS) • C finishes. • A and C finish.
Multiprocessor Scheduling (cont’) B D A Queue2 Queue1 CPU: B D Queue2 Queue1 CPU: • Multi-queue multiprocessor scheduling (MQMS) • Solution: migration
Multiprocessor Scheduling (cont’) Source: http://www.tanveernaseer.com/how-to-manage-a-co-worker-who-takes-credit-for-your-work (Retrieved on 2015 / 04 / 28) • Multi-queue multiprocessor scheduling (MQMS) • Solution: migration • Work stealing • A source queue that is low on jobs • Cccasionally peek at another target queue. • If the target queue is more full than the source queue • The source will stealjobs. • If it looks around at other queues too often • It would suffer from high overhead. • If it doesn’t look around at other queues very often • It would suffer from load imbalances.
Linux Multiprocessor Schedulers • No common solutions are there. • Over time, three different schedulers arose: • O(1) scheduler • Completely Fair Scheduler (CFS) • BF Scheduler (BFS)
Summary • Issues of the multiprocessor • Cache coherence • Synchronization • Cache affinity • Multiprocessor scheduling • Single-queue approach (SQMS) • Multiple-queue approach (MQMS)