Scheduler Activations - Effective Kernel Support for the User-Level Management of Parallelism
Upcoming SlideShare
Loading in...5
×
 

Scheduler Activations - Effective Kernel Support for the User-Level Management of Parallelism

on

  • 2,345 views

Presentation slides presented by Kasun Gajasinghe and Nisansa de Silva at Dept. of Computer Science & Engineering, University of Moratuwa. Slides are for the paper titled “Scheduler Activations - ...

Presentation slides presented by Kasun Gajasinghe and Nisansa de Silva at Dept. of Computer Science & Engineering, University of Moratuwa. Slides are for the paper titled “Scheduler Activations - Effective Kernel Support for the User-Level Management of Parallelism” by Thomas E. Anderson et.al.

Statistics

Views

Total Views
2,345
Views on SlideShare
2,344
Embed Views
1

Actions

Likes
0
Downloads
39
Comments
0

1 Embed 1

http://www.docshut.com 1

Accessibility

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

CC Attribution-NonCommercial LicenseCC Attribution-NonCommercial License

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • This way, when a thread blocks on a user-level lock or condition variable, the thread scheduler can resume running without kernel intervention.
  • Inform that 2 threads have stopped!
  • an additional preemption may have to take place beyond the ones described above. For inst ante, on an I/0 completion, some processor could be running a thread with a lower priority than both the unblocked and the preempted thread. In that case, the user-level thread system can ask the kernel to interrupt the thread running on that processor and start a scheduler activation once the thread has been stopped. The user level can know to do this because it knows exactly which thread is running on each of its processors. the kernel’s interaction with the application is entirely in terms of scheduler activations. The application is free to build any other concurrency model on top of scheduler activations; the kernel’s behavior is exactly the same in every case. In particular, the kernel needs no knowledge of the data structures used to represent parallelism at the user level.
  • More runnable threads than processors More processors than runnable threads If an applicatlon has notified the kernel that it has idle processors, and the kernel has not taken them away, then there must be no other work in the system, and the kernel need not be notified of changes in parallelism, up to the point where the application has more work than processors. These notifications are only hints: if the kernel gives an address space a processor that is no longer needed by the time it gets there, the address space simply returns the processor to the kernel with the updated information. Of course, the user-level thread system must serialize its notifications to the kernel, since ordering matters.
  • This encourages address spaces to give up processors when they are needed elsewhere, since the priorities imply that it is likely that the processors will be returned when they are needed. This avoids the overhead of processor re-allocation when the work is created.
  • because other threads continue to test an application-level spin-lock held by the preempted thread the preempted thread could be holding a lock on the user-level thread ready list; if so, deadlock would occur if the upcall attempted to place the preempted thread onto the ready list

Scheduler Activations - Effective Kernel Support for the User-Level Management of Parallelism Scheduler Activations - Effective Kernel Support for the User-Level Management of Parallelism Presentation Transcript

  • SCHEDULER ACTIVATIONS Effective Kernel Support for the User-Level Management of Parallelism Kasun Gajasinghe Nisansa de Silva University of Moratuwa Based on the paper “Scheduler Activations - Effective Kernel Support for the User-Level Management of Parallelism” by Thomas E. Anderson et.al.
  • Scheduler Activations
      • Introduction to Threads
    •  
      • User-Level and Kernel-Level Threads
        • Implementation
        • Pros and Cons
    •  
      • Effective Kernel Support for User-Level Management of Parallelism
        • Scheduler Activations
          • Design
          • Implementation
          • Performance
    •  
      • Conclusion
  • What is a Thread?
      • Smallest unit of processing that can be scheduled by the operating system
    •  
      • Similar to a process
    •  
      • Separate “thread of execution”
    •  
    •  
      • Each thread has a separate stack, program counter, and run state
  • Why Threads?
      • Perform operations in parallel on the same data
    •  
      • Avoid complex explicit scheduling by applications
    •  
      • Often more efficient than separate processes
    •  
      • Remain responsive for user inputs
  • Implementing Threads
    • Three basic strategies
      • User-level: possible on most operating systems, even ancient ones
    •  
      • Kernel-level: looks almost like a process (i.e., Linux, Solaris)
    •  
      • Scheduler activations (Digital Tru Unix 64, NetBSD, some Mach)
  •  
    •  
      User Thread      Kernel Thread
  • Thread System - User Level
      • Thread library’s code + data structures in user space
    •  
      • Invocation of library function = local function call. Not system call
    •  
      • Pros -
        • Good performance
          • Fast thread context switching
          • Better Scaling
        • Highly flexible
          • Custom scheduling algorithms 
      • Cons -
        • Poor concurrency support 
          • blocking system calls starve sibling threads
  • Thread System - System Level
      • Thread library’s code + data structures in kernel space
    •  
      • Invocation of library function = system call
    •  
      • Pros -
        • Good concurrency support
          • Blocking system calls do not starve sibling threads 
    •  
      • Cons - 
        • Poor performance
          • Operations involve system calls
          • Full context switch to perform thread switches
        • Less Flexible
          • Generic scheduling Algorithm
    •  
    • User Threads
      • Excellent performance
    •  
      • No system calls to perform thread operations
    •  
      • More flexible =>Can use domain specific scheduling algorithm (‘customized’ thread library)
    •  
      • Blocking system calls such as I/O problematic; Starvation of sibling threads
    • Kernel Threads
      • Bad performance 
    •  
      • System calls needed to perform thread operations
    •  
      • Generic scheduling algorithm( scheduled by kernel)
    •  
      • Good integration with system services –
        • blocking calls do not prevent other user threads from being scheduled. 
        • Less likelihood of starvation
  •  
    • Fig. Thread Operation Latencies (micro seconds)
    • Topaz - A highly tuned kernel. 
    • FastThreads - A user-level thread library
    • Ultrix - BSD family unix-like OS
  • SCHEDULER ACTIVATIONS  
  • Scheduler Activations
      • Get the best of both worlds —
        • The efficiency and flexibility of user-level threads
        • The non-blocking ability of kernel threads (Poor integration with system services)
    •  
      • Relies on upcalls
    •  
      • The term “scheduler activation” was selected because each vectored event causes the user-level thread system to reconsider its scheduling decision of which threads to run on which processors. 
  • Scheduler Activations
    • What’s an Upcall?
      • Normally, user programs call functions in the kernel. Which call as system calls
    •  
      • Sometimes, though, the kernel calls a user-level process to report an event
    •  
      • Sometimes considered unclean — violates usual layering
  • Scheduler Activations
      • Thread creation and scheduling is done at user level
    •  
      • When a system call from a thread blocks, the kernel does an upcall to the thread manager
    •  
      • The thread manager marks that thread as blocked, and starts running another thread
    •  
      • When a kernel interrupt occurs that’s relevant to the thread, another upcall is done to unblock it
  • Scheduler Activations
    •  
  • Scheduler Activations
    • It serves as a vessel, or execution context, for running user-level threads, in exactly the same way that a kernel thread does.
    • It notifies the user-level thread system of a kernel event.
    • It provides space in the kernel for saving the processor context of the activation’s current user-level thread, when the thread is stopped by the kernel (e.g., because the thread blocks in the kernel on I/0 or the kernel preempts its processor).
  • Scheduler Activations
    • Two execution stacks
    • One mapped into the kernel
    • one mapped into the application address space.
    Kernel Application Address space
  • Scheduler Activations
    • kernel stack is used whenever the user-level thread running in the scheduler activation’s context executes in the kernel (e.g. system call)
    • The kernel also maintains a control block for each activation (akin to a thread control block) to record the state of the scheduler activation when its thread blocks in the kernel or is preempted.
    Kernel Application Address space
  • Scheduler Activations
    • The user-level thread scheduler runs on the activation’s user-level stack and maintains a record of which user-level thread is running in which scheduler activation.
    • Each user-level thread is allocated its own stack when it starts running
    Kernel Application Address space
  • Scheduler Activations - Programs Kernel Application 1 Address space
  • Scheduler Activations - Programs Kernel Application 1 Address space
  • Scheduler Activations - Upcalls Kernel Application 1 Address space
  • Scheduler Activations – thread stopping
    • The crucial distinction between scheduler activations and kernel threads is that once an activation’s user-level thread is stopped by the kernel, the thread is never directly resumed by the kernel.
  • Scheduler Activations – thread stopping
    • A new scheduler activation is created to notify the user-level thread system that the thread has been stopped.
    • The user-level thread system removes the state of the thread from the old activation,
    • Tells the kernel that the old activation can be re-used (Explained later)
    • Decides which thread to run on the processor.
  • Scheduler Activations – thread stopping
    • The kernel is able to maintain the invariant that there are always exactly as many running scheduler activations (vessels for running user-level threads) as there are processors assigned to the address space.
  • Scheduler Activations -Blocking Kernel Application 1 Address space
  • Scheduler Activations -Blocking Kernel Application 1 Address space
  • Scheduler Activations -Blocking Kernel Application 1 Address space 
  • Scheduler Activations -Blocking Kernel Application 1 Address space
  • Scheduler Activations -Blocking Kernel Application 1 Address space 
  • Scheduler Activations -Blocking Kernel Application 1 Address space  P
  • Scheduler Activations -Multiprogramming Application 2 Address space Kernel Application 1 Address space
  • Scheduler Activations -Multiprogramming Application 2 Address space Kernel Application 1 Address space P
  • Scheduler Activations - Additional
    • if threads have priorities, and there exists running thread with a lower priority than both the unblocked and the preempted thread.
    • Application concurrency model
  • Scheduler Activations – Upcall Points
  • Scheduler Activations – Address space to Kernel
  • Scheduler Activations - Enhancements
    • The processor allocator can favour address spaces that use fewer processors and penalize those that use more.
    • If overall the system has fewer threads than processors, the idle processors should be left in the address spaces most likely to create work in the near future.
  • Scheduler Activations – Critical sections
    • A user-level thread could be executing in a critical section at the instant when it is blocked or preempted.
      • Poor performance
      • Deadlock
    • Use “Recovery” instead of “Prevention”
  • Scheduler Activations –Critical section Kernel Application 1 Address space P User level context switch!
  • Implementation
    • Topaz kernel thread management system
      • Where Topaz formerly blocked, resumed, or preempted a thread, it now performs upcalls to allow the user level to take these actions
      • Do explicit allocation of processors to address spaces
    • Fast threads
      • Process upcalls
      • Resume interrupted critical sections
      • Provide Topaz with needed infomation
  • Implementation
    • Topaz kernel thread management system
      • Add 1200 lines (on 4000)
      • Mostly processor allocation policy
    • Fast threads
      • Few hundred lines
    • NB: design is “neutral” on the choice of policies for allocating processors to address spaces and for scheduling threads onto processors.
  • Implementation– Processor Allocation Policy
    • Processors are divided evenly among address spaces
    • if some address spaces do not need all of the processors in their share, those processors are divided evenly among the remainder.
    • processors are time-sliced only if the number of available processors is not an integer multiple of the number of address spaces.
    • The kernel processor allocator only needs to know whether each address space could use more processors or has some processors that are idle.
  • Implementation– Thread Scheduling Policy
    • kernel has no knowledge of an application’s concurrency model or scheduling policy, or of the data structures used to manage parallelism at the user level.
    • Each application is completely free to choose these as appropriate; they can be tuned to fit the application’s needs.
  • Performance Enhancements– Critical sections
    • Have a duplicate code section of the critical section
    • At the end of the copy (Only!) put code to yield the processor back to the resumer.
  • Performance Enhancements– Critical sections
    • Normal execution uses the original code.
    • When a preemption occurs, the kernel starts a new scheduler activation to notify the user-level thread system
    • This activation checks the preempted thread’s program counter to see if it was in one of these critical sections
    • If so, continue the thread at the corresponding place in the copy of the critical section. The copy relinquishes control back to the original upcall at the end of the critical section.
  • Performance Enhancements– UPCalls
    • Logically, a new scheduler activation is created for each upcall.
    • Creating a new scheduler activation is not free, however, because it requires data structures to be allocated and initialized.
    • Instead, discarded scheduler activations can be cached for eventual re-use. (Remember?  )
  • Performance Enhancements– Debugging
    • Not very significant to note
    • The point is that you have to use a debugger which have as little effect as possible on the sequence of instructions being debugged.
  • Performance
      • Thread performance - without kernel involvement quite similar to FastThreads before the changes.
    •  
      • Upcall performance - significantly worse than Topaz threads.
        • Untuned implementation.
        • Topaz in assembler, this system in Modula-2+.
    •  
      • Application performance -
        • Negligible I/O: As quick as original FastThreads.
        • With I/O: Performs better than either FastThreads or    Topaz threads.
  • Performance
    •  
  • Performance
    •  
  • Performance
    •  
  • Summary
      • Processor allocation (the allocation of processors to address spaces) is done by the kernel.
    •  
      • Thread scheduling (the assignment of an address space’ threads to its processors) is done by each address space.
    •  
      • The kernel notifies the address space thread scheduler of every event affecting the address space.
    •  
      • The address space notifies the kernel of the subset of user-level events that can affect processor allocation decisions.
  • THANK YOU!