Presentation is loading. Please wait.

Presentation is loading. Please wait.

BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling1 Chapter 10 Multiprocessor and Real-Time Scheduling.

Similar presentations


Presentation on theme: "BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling1 Chapter 10 Multiprocessor and Real-Time Scheduling."— Presentation transcript:

1 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling1 Chapter 10 Multiprocessor and Real-Time Scheduling

2 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling2 Classifications of Multiprocessors Loosely coupled multiprocessor. each processor has its own memory and I/O channels Functionally specialized processors. such as I/O processor controlled by a master processor Tightly coupled multiprocessing. processors share main memory controlled by operating system Multiprocessors

3 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling3 Synchronization Granularity Multiprocessors Grain SizeDescriptionUses Synchronization Interval (Instructions) Fine Parallelism inherent in a single instruction stream ?< 20 Medium Parallel processing or multitasking within a single application Threads w/in application 20 to 200 Coarse Multiprocessing of concurrent processes in a multiprogramming environment Unix pipes200 to 2000 Very Coarse Distributed processing across network nodes to form a single computing environment Make File applications 2000 to 1M Independent Multiple unrelated processes Time-sharing(N/A)

4 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling4 Independent Parallelism Separate processes running. No synchronization. An example is time sharing. average response time to users is less more cost-effective than a distributed system Memory P0P0 P1P1 P2P2 P3P3 Parallelism

5 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling5 Very Coarse Parallelism Distributed processing across network nodes to form a single computing environment. In general, any collection of concurrent processes that need to communicate or synchronize can benefit from a multiprocessor architecture. good when there is infrequent interaction network overhead slows down communications Network Memory P0P0 P1P1 P2P2 P3P3 Parallelism

6 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling6 Coarse Parallelism Similar to running many processes on one processor except it is spread to more processors. true concurrency synchronization Multiprocessing. Memory P0P0 P1P1 P2P2 P3P3 Parallelism

7 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling7 Medium Parallelism Parallel processing or multitasking within a single application. Single application is a collection of threads. Threads usually interact frequently. Memory P0P0 P1P1 P2P2 P3P3 Parallelism

8 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling8 Fine-Grained Parallelism Much more complex use of parallelism than is found in the use of threads. Very specialized and fragmented approaches. Memory P0P0 P1P1 P2P2 P3P3 Parallelism

9 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling9 Assigning Processors How are processes/threads assigned to processors? Static assignment. Advantages Dedicated short-term queue for each processor. Less overhead in scheduling. Allows for group or gang scheduling. Process remains with processor from activation until completion. Disadvantages One or more processors can be idle. One or more processors could be backlogged. Difficult to load balance. Context transfers costly. Scheduling

10 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling10 Assigning Processors Who handles the assignment? Master/Slave Single processor handles O.S. functions. One processor responsible for scheduling jobs. Tends to become a bottleneck. Failure of master brings system down. Peer O.S. can run on any processor. More complicated operating system. Generally use simple schemes. Overhead is a greater problem Threads add additional concerns CPU utilization is not always the primary factor. Scheduling

11 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling11 Process Scheduling Single queue for all processes. Multiple queues are used for priorities. All queues feed to the common pool of processors. Specific scheduling disciplines is less important with more than one processor. Simple FCFS discipline or FCFS within a static priority scheme may suffice for a multiple-processor system. Scheduling

12 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling12 Thread Scheduling Executes separate from the rest of the process. An application can be a set of threads that cooperate and execute concurrently in the same address space. Threads running on separate processors yields a dramatic gain in performance. However, applications requiring significant interaction among threads may have significant performance impact w/multi-processing. Scheduling

13 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling13 Multiprocessor Thread Scheduling Load sharing processes are not assigned to a particular processor Gang scheduling a set of related threads is scheduled to run on a set of processors at the same time Dedicated processor assignment threads are assigned to a specific processor Dynamic scheduling number of threads can be altered during course of execution Scheduling

14 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling14 Load Sharing Load is distributed evenly across the processors. Select threads from a global queue. Avoids idle processors. No centralized scheduler required. Uses global queues. Widely used. FCFS Smallest number of threads first Preemptive smallest number of threads first Scheduling

15 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling15 Disadvantages of Load Sharing Central queue needs mutual exclusion. may be a bottleneck when more than one processor looks for work at the same time Preemptive threads are unlikely to resume execution on the same processor. cache use is less efficient If all threads are in the global queue, all threads of a program will not gain access to the processors at the same time. Scheduling

16 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling16 Gang Scheduling Schedule related threads on processors to run at the same time. Useful for applications where performance severely degrades when any part of the application is not running. Threads often need to synchronize with each other. Interacting threads are more likely to be running and ready to interact. Less overhead since we schedule multiple processors at once. Have to allocate processors. Scheduling

17 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling17 Dedicated Processor Assignment When application is scheduled, its threads are assigned to a processor. Advantage: Avoids process switching Disadvantage: Some processors may be idle Works best when the number of threads equals the number of processors. Scheduling

18 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling18 Dynamic Scheduling Number of threads in a process are altered dynamically by the application. Operating system adjusts the load to improve use. assign idle processors new arrivals may be assigned to a processor that is used by a job currently using more than one processor hold request until processor is available new arrivals will be given a processor before existing running applications Scheduling

19 Real-Time Scheduling

20 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling20 Real-Time Systems Correctness of the system depends not only on the logical result of the computation but also on the time at which the results are produced. Tasks or processes attempt to control or react to events that take place in the outside world. These events occur in real time and process must be able to keep up with them. Require results be produced before specified deadlines. Real-Time

21 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling21 Real-Time Systems Very common in embedded systems – a computing device whose presence is not obvious Hard real-time: missed deadlines result in damage or death safety-critical systems Soft real-time: missed deadlines may result in lower performance, but can be tolerated most real-time systems are soft real-time Real-Time Examples: Hard or Soft? Radiation treatment Wristwatch Router / Switch Fax machine Pacemaker AutomobileAirplane Process control plantsDishwasher / Furnace Laboratory experimentsTelecommunications Cell phoneAir traffic control Camera / MP3 playerRobotics

22 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling22 Characteristics of Real-Time OS Deterministic Operations are performed at fixed, predetermined times or within predetermined time intervals. Responsive – Minimal Latency Interrupt latency – time from the arrival of an interrupt at the CPU to the start of the interrupt service routine. Dispatch latency – time required for the scheduling dispatcher to stop one process and start another. Preemptive kernel. User control Single purpose, economical – system-on-chip (SOC) Configurable – paging, residency, rights Real-Time

23 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling23 Characteristics Reliable Degradation of performance may have catastrophic consequences. Preemptive, priority-based scheduling - most critical, high priority tasks execute Fail-Soft Operation Ability to handle system failures by gently reducing performance If a shutdown cant be avoided, then try to do so gracefully (Example: Fighter flight-control system that adjusts for damage to the system.) Stability - ability to meet the most important deadlines even if lower priority deadlines cannot be met. Real-Time

24 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling24 Features of RTOS Fast context switch – preemptive kernel Small size/minimal functionality (small footprint) Ability to respond to external interrupts quickly Multitasking with interprocess communication tools such as semaphores, signals, and events Files that accumulate data at a fast rate Preemptive scheduling with priority Minimize time with interrupts off Primitives to delay tasks for a fixed amount of time, pause/resume tasks Special alarms and timeouts Real-Time

25 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling25 Real-Time Scheduling Static table-driven Schedule periodic tasks in advance Changes result in redoing schedule Static priority-driven preemptive Takes advantage or priority-based scheduler Give higher priorities to real-time tasks Based on time constraints, importance Dynamic planning-based Try to revise schedule when a task arrives Dynamic best effort Assign priorities based on the task, such as earliest deadline Used by many real-time systems Easy to implement Hard to know if a deadline will be met Real-Time Scheduling

26 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling26 Deadline Scheduling Real-time applications are not concerned with speed but with completing tasks Scheduling tasks with the earliest deadline minimizes the fraction of tasks that miss their deadlines Includes new tasks and amount of time needed for existing tasks Earliest-Deadline-First

27 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling27 Two Periodic Tasks Execution profile of two periodic tasks Process A Arrives02040… Execution Time101010… End by204060… Process B Arrives050100… Execution Time252525… End by50100150… Question: Is there enough time for the execution of two periodic tasks? Earliest-Deadline-First

28 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling28 Earliest-Deadline-First Scheduling 2 Periodic Tasks

29 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling29 Five Periodic Tasks Execution profile of five periodic tasks Earliest-Deadline-First ProcessArrival Time Execution Time Starting Deadline A1020110 B20 C402050 D 2090 E602070 Question: Is there enough time for the execution of five periodic tasks?

30 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling30 Scheduling of Real-Time Tasks Earliest-Deadline-First

31 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling31 Rate Monotonic Scheduling The RMS algorithm schedules periodic tasks using a static priority policy with preemption. Upon entering the system, each periodic task is assigned a priority inversely based on its period: the shorter the period, the higher the priority. Gives higher priority to tasks that require the CPU more often Assumes processing time of a periodic process is always the same RMS guarantees, for a set of n periodic tasks with unique periods, a feasible schedule that will always meet deadlines exists if the CPU utilization is below a specific bound (depending on the number of tasks). Despite being optimal, RMS has a limitation - CPU utilization is bounded and it is not always possible to fully maximize CPU resources. RMS

32 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling32 Rate Monotonic Scheduling A simple version of rate-monotonic analysis assumes that threads have the following properties: No resource sharing (processes do not share resources, e.g. a hardware resource, a queue, or any kind of semaphore blocking or non-blocking (busy- waits)) Deterministic deadlines are exactly equal to periods Static priorities (the task with the highest static priority that is runable immediately preempts all other tasks) Static priorities assigned according to the rate monotonic conventions (tasks with shorter periods/deadlines are given higher priorities) Context switch times and other thread operations are free and have no impact on the model RMS

33 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling33 Rate Monotonic Scheduling Parameters P i = Time between arrivals of the task (period) T i = Time required to do calculation U i = CPU Utilization = T i / P i (55 ms / 80 ms = 0.6875) Give shortest-period task the highest priority If T i /P i n(2 1/n - 1), all n tasks can be successfully scheduled n(2 1/n - 1) 0.693 as n This formula is conservative (90% utilization can be done in practice) This formula also holds for earliest deadline scheduling RMS generally used over Deadline Performance difference small Handles soft real-time parts better Stability is easier to achieve RMS

34 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling34 Priority Inversion In many practical applications, resources are shared and the unmodified RMS will be subject to priority inversion and deadlock hazards. In scheduling, priority inversion is the scenario where a low priority task holds a shared resource that is required by a high priority task. This causes the execution of the high priority task to be blocked until the low priority task has released the resource, effectively "inverting" the relative priorities of the two tasks. If some other medium priority task, that does not depend on the shared resource, attempts to run in the interim, it will take precedence over both the low priority task and the high priority task. CS 345Homework #434

35 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling35 Mars Pathfinder Martian landing on July 4 th, 1997 Periodically experienced total system resets. VxWorks uses preemptive priority scheduling. Access to information bus synchronized with mutexes. Meteorological data gathering – low priority Communication task – medium priority Information bus manager – high priority Data gathering held mutex, bus manager was blocked, communication task running, watchdog timer reset. CS 345Homework #435

36 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling36 Priority Inversion Solutions Disabling all interrupts to protect critical sections Only two priorities: preemptible, and interrupts disabled, with no third priority - inversion is impossible. Since there's only one piece of lock data (the interrupt-enable bit), misordering locking is impossible, and so deadlocks cannot occur. Since the critical regions always run to completion, deadlock does not occur. Priority inheritance When priority is inherited, the low priority task inherits the priority of the high priority task, thus stopping a medium priority task from pre-empting the high priority task. A priority ceiling With priority ceilings, the shared mutex process (that runs the operating system code) has a characteristic (high) priority of its own, which is assigned to the task locking the mutex. This works well, provided the other high priority task(s) that try to access the mutex does not have a priority higher than the ceiling priority. CS 345Homework #436

37 VxWorks, Linux, Unix, Windows…

38 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling38 VxWorks Wind River Systems Hard real-time support automobiles industrial devices networking Spirit and Opportunity Wind micro-kernel tasks – execute in kernel mode preemptive and nonpreemptive RR w/256 priority levels bounded interrupt latency shared memory / pipes embedded real-time application POSIX library Java libraryfile systems TCP/IP virtual memory VxVMI graphics library Wind micro-kernel hardware level (Pentium, Power PC, MIPS, customized, etc.)

39 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling39 Linux Scheduling Standard kernel code non-preemptible Timer interrupts during kernel code sets a flag need_resched that causes rescheduling at the end of the kernel call Only need to avoid accessing user memory and disable interrupts during critical data structure operations Interrupt Service routines Top Half – Runs with equal or lower-priority interrupts disabled Bottom Half – Allow all interrupts Scheduler ensures a bottom half doesnt interrupt itself Kernel can disable selected bottom halves during critical sections Linux Scheduling

40 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling40 Linux Priorities Based on scheduling credits Select process with highest number of credits Loses one credit for each timer interrupt Suspended when no credits remaining If no runnable processes have credits, assign new credits to all processes: Credits = Credits/2 + priority Multiprocessor Scheduling First supported in 2.0.x kernel Finer locking, threaded subsystems in 2.3.x kernel Scheduler gives bonus if a thread is rescheduled on the same CPU Linux Scheduling

41 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling41 Linux Scheduler Three scheduling classes SCHED_FIFO: FIFO real-time Not interrupted unless: Higher priority FIFO thread is ready Tread blocks (such as I/O) Thread voluntarily yields CPU If interrupted, put in a queue If it is ready and has higher priority, the other thread is preempted SCHED_RR: round-robin real-time Like FIFO, but with a time quantum At the end of the quantum, another equal or higher-priority thread is scheduled SCHED_OTHER: non-real-time Only run when no real-time thread is ready Linux Scheduling

42 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling42 Real-time Linux Release 2.6 fully preemptive kernel more efficient scheduling algorithm runs in O(1) regardless of number of tasks in system kernel divided into modular components for easier porting RTLinux standard Linux kernel runs as a task real-time kernel handles all interrupts prevents standard Linux kernel from ever disabling interrupts includes rate-monotonic and earliest-deadline-first Real-time Linux Scheduling

43 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling43 UNIX Scheduling Set of 160 priority levels divided into three priority classes Basic kernel is not preemptive Priority Class Global Value Scheduling Sequence Real-time 159 100 first last Kernel 99 60 0 59 Time-shared.......... UNIX Scheduling

44 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling44 Unix SVR4 Scheduling Two major modifications: Addition of a preemptible static priority scheduler with three priority ranges Real-time (159 - 100) Kernel (99 - 60) User time-share (59 - 0) Insertion of preemption points into the kernel Allow the kernel to be interrupted at specified safe locations All resources are either not in use or locked via semaphore Combination allows real-time processes to run before the kernel, and preempt the kernel when necessary UNIX Scheduling

45 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling45 Win2000 Priorities Priority-driven preemptive scheduler 32 total priority levels Real-time processes use levels 31-16 Other processes use levels 15-0 Round-robin within each priority level Process base priority Thread base priority – Offset from the process base priority (max +/- 2) Thread dynamic priority Varies from process base priority Raised when the thread blocks Lowered when it uses its time quantum Multiprocessor scheduling N-1 highest-priority threads active Other threads share the remaining processor Windows Scheduling Process Priority Threads Base Priority Threads Dynamic Priority 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 base priority highest above normal normal below normal lowest

46 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling46 Embedded Systems 9 billion processors manufactured in 2005 2% used in new PCs, Macs, and Unix workstations 8.8 billion used in embedded systems Special-purpose computer systems designed to perform one or a few dedicated functions with real-time computing constraints Virtually every electronic device designed and manufactured today is an embedded system Digital watches, MP3 players, traffic lights, factory controllers, peripherals, toys, microwaves, dishwashers, thermostats, greeting cards, gas meter, smart batteries, EKG, weight scales, smoke detectors, irrigation systems, …

47 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling47 Handheld Measurement Air Flow measurement Alcohol meter Barometer Data loggers Emission/Gas analyser Humidity measurement Temperature measurement Weight scales Medical Instruments Blood pressure meter Blood sugar meter Breath measurement EKG system Home environment Air conditioning Control unit Thermostat Boiler control Shutter control Irrigation system White goods (Washing machine,..) Misc Smart card reader Taxi meter Smart Batteries Utility Metering Gas Meter Water Meter Heat Volume Counter Heat Cost Allocation Electricity Meter Meter reading system (RF) Sports equipment Altimeter Bike computer Diving watches Security Glass break sensors Door control Smoke/fire/gas detectors Typical Applications

48 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling48 Embedded Systems Benefits of embedded systems Reduced size Cost – mass produced Reliability – expected to run for years Performance – real-time events Portability – low-power Early systems Apollo guidance computer, 1960 Minuteman missile, 1961 Intel 4004 Flash/RAM

49 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling49 Embedded Systems User interfaces Buttons LEDs Touch sensors Joysticks GPIO Sensors D/A, A/D Universal Serial Communication Interface UART SPI I 2 C

50 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling50 Embedded Systems CPU platforms Von Neumann / Harvard RISC, CISC, VLIW 65x, 68x, 8051, PIC, ARM, Blackfin, Coldfire, eZ8x, MSP430, PowerPC, x86, Z80,… System on a chip (SOC) Application-specific integrated circuit (ASIC) Field-programmable gate array (FPGA) Single board computers (SBCs)

51 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling51 Embedded Systems Peripherals Serial communication interfaces (SCI): RS-232, RS-485, … Synchronous Serial Communication Interface: I 2 C, SPI, … Universal Serial Bus (USB) Networks: Ethernet, Controller Area Network, … Timers: PLLs, Capture/Compare, TPUs, … General Purpose Input/Output (GPIO) Analog to Digital / Digital to Analog (ADC/DAC) Debugging: JTAG, ISP, SPI-Wire, BDM Port… Tools Compilers, assemblers, debuggers In-circuit debuggers, emulators

52 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling52 Embedded Systems Architectures Simple control loop Interrupt controlled system (event driven) Cooperative multitasking Preemptive multitasking Synchronization Message queues Semaphores Non-blocking synchronization Real-time OS Microkernels / exokernels Monolithic kernels: Embedded Linux, Windows CE

53 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling53 MSP430 Roadmap

54 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling54 PIC Roadmap

55 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling55 ARM Roadmap

56 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling56 8051 Roadmap

57 BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling57 Lots of RTOSs BRMLABS/7RMX-80, RMX-86RTTS BLMXMERTRPSRTUX BSO/RTOSMINI-EXECRSX-11RTX C ExecutiveMIRAGERSX-15RTX-16 CCPMOSSRTE-I, RTE-II, RTE-III, RTE-IVRTX-16 CTOSMROS-68KRTE-6/VMRx CTRONMSP/7RTE-ASAX DES RTMSPRTEXSIGMA 7 OS DMERTMTK-IIRTMOSSPHERE DSOSOS/32-ST and OS/32-MTRTM8STARPLEX II E4OS/700RTMSTRON EDXOS/RTRTOSUSX EIS-110pRTOSVAXELN Executive IIPDOSRTOSVORTEX FADOSPORTXRTOSVRTX GEMpSOSRTOS-16 iRMXReduced Core MonitorRTOS/360 ITRONRMS09, RMS68KRTR


Download ppt "BYU CS 345Chapter 10 - Multiprocessor and Read-Time Scheduling1 Chapter 10 Multiprocessor and Real-Time Scheduling."

Similar presentations


Ads by Google