Multiprocessor Scheduling
SHOAIB MANZOOR
F19-MSCS-5020
Multicore Processors
 Multiple CPU cores are packed into single chip.
 Making single CPU too fast by this technique.
Difficulties in Multicore
 C Program uses only one CPU.
 Adding more CPUs doesn’t make the program run faster.
 To OVERCOME this difficulty we need to rewrite the C program to run in parallel
(Threads).
Difference B/W Single CPU and Multi-CPU
Hardware
 Use of Hardware Caches.
 Caches are small, fast memories that hold copies of popular data.
Temporal locality and spatial locality
 Temporal locality is that when a piece of data is accessed, it is likely to be
accessed again in the near future. E.g. Loop
 Spatial locality is that if a program accesses a data item at address x, it is likely
to access data items near x as well. E.g. Arrays
Cache Coherence
 Multiple processors with single shared memory.
Bus Snooping
 Each cache pays attention to memory updates by observing the bus that
connects them to main memory.
 it will notice the change.
 Then it will remove it from its cache or it will update the data.
Locking
 In this case, allocating a simple mutex (e.g., pthread mutex tm;)
and then adding a lock at the beginning of the routine and an
unlock at the end will solve the problem, ensuring that the code will
execute as desired.
Cache Affinity
 One process is running on CPU1 and then terminates and wants to run again it will
run fast on CPU!.
 But if this process will run on diff processor every time then performance of this
process will be worse because each time it has to reload state each time.
SQMS
 Single Queue Multiprocessor Scheduling.
 Reuse the basic framework for single processor scheduling, by putting all jobs that
need to be scheduled into a single queue.
Problems in SQMS
 Lack of Scalability
 Cache Affinity
Overcome to Cache Affinity
Multi-Queue Scheduling
 Problems caused in single-queue schedulers, some systems opt for multiple
queues, e.g., one per CPU.
 By using RR system will behave like this
MQS Drawback and Solution
 What if A and C finishes ealrly?
 Solution:
 Migration is the only option to overcome this drawback.
Linux Multiprocessor Schedulers
 O(1) scheduler.
 Completely Fair Scheduler (CFS).
 BF Scheduler (BFS).
 Both O(1) and CFS use multiple queues, whereas BFS uses a single queue,
Thank you
Any Question???

Multiprocessor Scheduling

  • 1.
  • 2.
    Multicore Processors  MultipleCPU cores are packed into single chip.  Making single CPU too fast by this technique.
  • 3.
    Difficulties in Multicore C Program uses only one CPU.  Adding more CPUs doesn’t make the program run faster.  To OVERCOME this difficulty we need to rewrite the C program to run in parallel (Threads).
  • 4.
    Difference B/W SingleCPU and Multi-CPU Hardware  Use of Hardware Caches.  Caches are small, fast memories that hold copies of popular data.
  • 5.
    Temporal locality andspatial locality  Temporal locality is that when a piece of data is accessed, it is likely to be accessed again in the near future. E.g. Loop  Spatial locality is that if a program accesses a data item at address x, it is likely to access data items near x as well. E.g. Arrays
  • 6.
    Cache Coherence  Multipleprocessors with single shared memory.
  • 7.
    Bus Snooping  Eachcache pays attention to memory updates by observing the bus that connects them to main memory.  it will notice the change.  Then it will remove it from its cache or it will update the data.
  • 8.
    Locking  In thiscase, allocating a simple mutex (e.g., pthread mutex tm;) and then adding a lock at the beginning of the routine and an unlock at the end will solve the problem, ensuring that the code will execute as desired.
  • 9.
    Cache Affinity  Oneprocess is running on CPU1 and then terminates and wants to run again it will run fast on CPU!.  But if this process will run on diff processor every time then performance of this process will be worse because each time it has to reload state each time.
  • 10.
    SQMS  Single QueueMultiprocessor Scheduling.  Reuse the basic framework for single processor scheduling, by putting all jobs that need to be scheduled into a single queue.
  • 11.
    Problems in SQMS Lack of Scalability  Cache Affinity
  • 12.
  • 13.
    Multi-Queue Scheduling  Problemscaused in single-queue schedulers, some systems opt for multiple queues, e.g., one per CPU.  By using RR system will behave like this
  • 14.
    MQS Drawback andSolution  What if A and C finishes ealrly?  Solution:  Migration is the only option to overcome this drawback.
  • 15.
    Linux Multiprocessor Schedulers O(1) scheduler.  Completely Fair Scheduler (CFS).  BF Scheduler (BFS).  Both O(1) and CFS use multiple queues, whereas BFS uses a single queue,
  • 16.
  • 17.