0 5 10 15 20 1 Slide 3 Performance of Round-Robin Sche

0 5 10 15 20 1 Slide 3 Performance of Round-Robin Sche

Performance of round-robin scheduling: LAST LECTURE ➜ Average waiting time: not optimal ➜ Performance depends heavily on size of time-quantum: Scheduling Algorithms: - too short: overhead for context switch becomes too ➜ Slide 1 FIFO Slide 3 expensive ➜ Shortest job next - too large: degenerates to FCFS policy ➜ Shortest remaining job next - rule of thumb: about 80% of all bursts should be shorter than ➜ Highest Response Rate Next (HRRN) 1 time quantum ➜ no starvation ROUND-ROBIN PRIORITIES quantum=1: ➜ A Each thread is associated with a priority B ➜ Basic mechanism to influence scheduler decision: C D • Scheduler will always choose a thread of higher priority over E one of lower priority 0 5 10 15 20 • Implemented via multiple FCFS ready queues (one per Slide 2 quantum=4: Slide 4 priority) A ➜ Lower-priority may suffer starvation B C • adapt priority based on thread’s age or execution history D E ➜ Priorities can be defined internally or externally 0 5 10 15 20 - internal: e.g., memory requirements, I/O bound vs CPU ➜ Scheduled thread is given a time slice bound ➜ Running thread is preempted upon clock interrupt, running - external: e.g., importance of thread, importance of user thread is returned to ready queue ROUND-ROBIN 1 PRIORITIES 2 Feedback scheduling: RQ0 Release Admit Processor Priority queueing: Queue Runable processes headers RQ1 Release Processor Priority 4 (Highest priority) Slide 5 Slide 7 ¥ ¥ ¥ Priority 3 ¥ ¥ ¥ Priority 2 RQn Release Processor Priority 1 (Lowest priority) Priorities influence access to resources, but do not guarantee a certain fraction of the resource (CPU etc)! Feedback scheduling: 0 5 10 15 20 LOTTERY SCHEDULING A ➜ process gets “lottery tickets” for various resources Feedback B q = 1 C ➜ more lottery tickets imply better access to resource D E Advantages: Slide 6 A Slide 8 Feedback i B ➜ Simple q = 2 C D ➜ Highly responsive E ➜ Allows cooperating processes/threads to implement individual ➜ Penalize jobs that have been running longer scheduling policy (exchange of tickets) i ➜ q =2 : longer time slice for lower priority (reduce starvation) PRIORITIES 3 LOTTERY SCHEDULING 4 Example (taken from Embedded Systems Programming: Four processes a running concurrently ➜ Process A: 15% of CPU time Note: UNIX traditionally uses counter-intuitive priority ➜ Process B: 25% of CPU time representation (higher value = less priority) ➜ Process C: 5% of CPU time Bands: ➜ Process D: 55% of CPU time ➜ Decreasing order of priority Slide 9 How many tickets should each process get to achieve this? Slide 11 • Swapper Number of tickets in proportion to CPU time, e.g., if we have • Block I/O device control • 20 tickets overall File manipulation • Character I/O device control ➜ Process A: 15% of tickets: 3 • User processes ➜ Process B: 25% of tickets: 5 ➜ Process C: 5% of tickets: 1 ➜ Process D: 55% of tickets: 11 TRADITIONAL UNIX SCHEDULING (SVR3, 4.3 BSD) Objectives: Advantages: ➜ support for time sharing ➜ ➜ good response time for interactive users relatively simple, effective ➜ ➜ support for low-priority background jobs works well for single processor systems Disadvantages: Slide 10 Strategy: Slide 12 ➜ ➜ Multilevel feedback using round robin within priorities significant overhead in large systems (recomputing priorities) ➜ ➜ Priorities are recomputed once per second response time not guaranteed ➜ non-preemptive kernel: lower priority process in kernel mode • Base priority divides all processes into fixed bands of priority can delay high-priority process levels • Priority adjustment capped to keep processes within bands ➜ Favours I/O-bound over CPU-bound processes TRADITIONAL UNIX SCHEDULING (SVR3,4.3BSD) 5 NON-PREEMPTIVE VS PREEMPTIVE KERNEL 6 Local memory CPU Complete system NON-PREEMPTIVE VS PREEMPTIVE KERNEL M M M M C C C C C C C C C+ M C+ M C+ M ➜ kernel data structures have to be protected C M C Inter- C M Shared C ➜ connect Internet basically, two ways to solve the problem: memory M C C M C C • Non-preemptive: disable all (most) interrupts while in kernel C C C C C C C C C+ M C+ M C+ M mode, so no other thread can get into kernel mode while in M M M M critial section (a) (b) (c) Slide 13 - Priority inversion possible Slide 15 - Coarse grained (b) Loosely coupled multiprocessor - Works only for uniprocessor • Each processor has its own memory and I/O channels • Preemptive: just lock kernel data structure which is currently • Generally called a distributed memory multiprocessor modified (c) Distributed System - More fine-grained • complete computer systems connected via wide area - Introduces additional overhead, can reduce throughput network • communicate via message passing MULTIPROCESSOR SCHEDULING What kind of systems and applications are there? PARALLELISM Classification of Multiprocessor Systems: Independent parallelism: Local memory CPU Complete system ➜ Separate applications/jobs M M M M ➜ No synchronization C C C C C C C C C+ M C+ M C+ M ➜ Parallelism improves throughput, responsiveness C M C Inter- C M Shared C connect Internet ➜ Slide 14 memory M C C M Slide 16 Parallelism doesn’t affect execution time of (single threaded) C C C C C C programs C C C C C+ M C+ M C+ M M M M M Coarse and very coarse-grained parallelism: (a) (b) (c) ➜ Synchronization among processes is infrequent (a) Tightly coupled multiprocessing ➜ Good for loosely coupled multiprocessors • Processors share main memory, controlled by single • Can be ported to multiprocessor with little change operating system, called symmetric multi-processor (SMP) system MULTIPROCESSOR SCHEDULING 7 PARALLELISM 8 Medium-grained parallelism: ASSIGNMENT OF THREADS TO PROCESSORS ➜ Parallel processing within a single application ➜ • Application runs as multithreaded process Treat processors as a pooled resource and assign threads to processors on demand ➜ Threads usually interact frequently ➜ Good for SMP systems • Permanently assign threads to a processor ➜ Unsuitable for loosely-coupled systems - Dedicate short-term queue for each processor ✔ Slide 17 Slide 19 Low overhead Fine-grained parallelism: ✖ Processor could be idle while another processor has a ➜ Highly parallel applications backlog • e.g., parallel execution of loop iterations • Dynamically assign process to a processor ✖ ➜ Very frequent synchronisation higher overhead ✖ poor locality ➜ Works only well on special hardware ✔ better load balancing • vector computers, symmetric multithreading (SMT) hardware MULTIPROCESSOR SCHEDULING Multiprocessor Scheduling: ASSIGNMENT OF THREADS TO PROCESSORS Which process should be run next and where? Who decides which thread runs on which processor? We discuss: Master/slave architecture: ➜ Tightly coupled multiprocessing ➜ Key kernel functions always run on a particular processor ➜ Very coarse to medium grained parallelism Slide 18 Slide 20 ➜ Master is responsible for scheduling ➜ Homogeneous systems (all processors have same specs, access ➜ Slave sends service request to the master to devices) ✔ simple Design Issues: ✔ one processor has control of all resources, no synchronisation ➜ How to assign processes/threads to the available processors? ✖ Failure of master brings down whole system ➜ Multiprogramming on individual processors? ✖ Master can become a performance bottleneck ➜ Which scheduling strategy ? ➜ Scheduling dependend processes ASSIGNMENT OF THREADS TO PROCESSORS 9 ASSIGNMENT OF THREADS TO PROCESSORS 10 LOAD SHARING: TIME SHARING 0 1 2 3 0 1 2 3 0 1 2 3 4 5 6 7 CPU A 5 6 7 A 5 6 7 CPU 12 8 9 10 11 CPU 4 8 9 10 11 goes idle 8 9 10 11 goes idle 12 13 14 15 12 13 14 15 B 13 14 15 Priority Priority Priority Peer architecture: 7 A B C 7 B C 7 C 6 D E 6 D E 6 D E 5 F 5 F 5 F ➜ Operating system can execute on any processor 4 4 4 3 G H I 3 G H I 3 G H I ➜ 2 J K 2 J K 2 J K Each processor does self-scheduling 1 1 1 ➜ 0 L M N 0 L M N 0 L M N Slide 21 Complicates the operating system Slide 22 (a) (b) (c) - Make sure no two processors schedule the same thread ➜ Load is distributed evenly across the processors - Synchronise access to resources ➜ Use global ready queue ➜ Proper symmetric multiprocessing • Threads are not assigned to a particular processor • Scheduler picks any ready thread (according to scheduling policy) • Actual scheduling policy less important than on uniprocessor ➜ No centralized scheduler required Disadvantages of time sharing: ➜ Central queue needs mutual exclusion • Potential race condition when several CPUs are trying to pick a thread from ready queue • May be a bottleneck blocking processors Slide 23 ➜ Preempted threads are unlikely to resume execution on the same processor • Cache use is less efficient, bad locality ➜ Different threads of same process unlikely to execute in parallel • Potentially high intra-process communication latency ASSIGNMENT OF THREADS TO PROCESSORS 11 LOAD SHARING: TIME SHARING 12 GANG SCHEDULING Combined time and space sharing: ➜ Simultaneous scheduling of threads that make up a single process Thread A running 0 ➜ Useful for applications where performance severely degrades when any part of the application is not running A B A B A B CPU 0 0 0 0 0 0 0 • e.g., often need to synchronise with each other Request 2 Request 1 CPU Slide 24 Reply 1 Reply 2 Slide 26 0 1 2 3 4 5 CPU 1 B1 A1 B1 A1 B1 A1 0 A0 A1 A2 A3 A4 A5 C 1 B0 B1 B2 0 C1 C2 Time 0 100 200 300 400 500 600 2 D0 D1 D2 D3 D4 E0 Time 3 E1 E2 E3 E4 E5 E6 slot 4 A0 A1 A2 A3 A4 A5 5 B0 B1 B2 C0 C1 C2 6 D0 D1 D2 D3 D4 E0 7 E1 E2 E3 E4 E5 E6 SMP SUPPORT IN MODERN GENERAL PURPOSE OS’Sa LOAD SHARING: SPACE SHARING ➜ Solaris 8.0: up to 128 ➜ Linux 2.4: up to 32 Scheduling

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    21 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us