Threads - WPI

Threads - WPI

OPERATING SYSTEMS Threads Jerry Breecher 4: Threads 1 OPERATING SYSTEM Threads What Is In This Chapter?

Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads 4: Threads 2 Single and Multithreaded

Processes THREADS 4: Threads 3 Benefits THREADS Responsiveness Resource Sharing Economy Utilization of MP Architectures 4: Threads

4 THREADS User Threads Thread management done by user-level threads library Examples - POSIX Pthreads - Mach C-threads - Solaris threads Supported by the Kernel Examples - Windows - Solaris - Tru64 UNIX

- BeOS - Linux Kernel Threads 4: Threads 5 THREADS Scheduling 4: Threads 6

Multithreading Models THREADS Many-to-One How do user and kernel threads map into each other? One-to-One 4: Threads 7 Many-to-One

THREADS Many user-level threads mapped to single kernel thread. Used on systems that do not support kernel threads. Examples: Solaris Green Threads GNU Portable Threads 4: Threads 8 One-to-One

THREADS Each user-level thread maps to kernel thread. Examples - Windows - Linux 4: Threads 9 Threading Issues THREADS Semantics of fork() and exec() system calls Does fork() duplicate only the calling thread or all threads? Thread cancellation

Terminating a thread before it has finished Two general approaches: Asynchronous cancellation terminates the target thread immediately Deferred cancellation allows the target thread to periodically check if it should be cancelled 4: Threads 10 Threading Issues THREADS Signal handling Signals are used in UNIX systems to notify a process that a particular event

has occurred A signal handler is used to process signals 1. Signal is generated by particular event 2. Signal is delivered to a process 3. Signal is handled Options: Deliver the signal to the thread to which the signal applies Deliver the signal to every thread in the process Deliver the signal to certain threads in the process Assign a specific thread to receive all signals for the process Thread pools Create a number of threads in a pool where they await work Advantages: Usually slightly faster to service a request with an existing thread than create a new thread Allows the number of threads in the application(s) to be bound to the size of the pool

4: Threads 11 Threading Issues THREADS Thread specific data Allows each thread to have its own copy of data Useful when you do not have control over the thread creation process (i.e., when using a thread pool) Scheduler activations Many:Many models require communication to maintain the appropriate number of kernel threads allocated to the application Scheduler activations provide upcalls - a communication mechanism from the kernel to the thread library

This communication allows an application to maintain the correct number kernel threads 4: Threads 12 THREADS Various Implementations PThreads A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization API specifies behavior of the thread library, implementation is up to development of the library Common in UNIX operating systems (Solaris, Linux, Mac OS X)

Windows Threads Implements the one-to-one mapping Each thread contains A thread id Register set Separate user and kernel stacks Private data storage area The register set, stacks, and private storage area are known as the context of the threads 4: Threads 13 THREADS Various Implementations

Linux Threads Linux refers to them as tasks rather than threads Thread creation is done through clone() system call clone() allows a child task to share the address space of the parent task (process) Java Threads Java threads may be created by: Extending Thread class Implementing the Runnable interface Java threads are managed by the JVM. 4: Threads 14 Threads WRAPUP Weve looked in detail at how threads work. Specifically weve

looked at: Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads 4: Threads 15

Recently Viewed Presentations

  • Welcome to our 2011 conference Nigel Magson Chair

    Welcome to our 2011 conference Nigel Magson Chair

    Welcome to our 2011 conference Your SIG Committee Steven Dodds Chair Stuart McCoy Vice Chair Liz Cook Adminstrative Assistant Anne Carter Treasurer Vacant Vice Treasurer Kirsty Neale Membership Vacant Digital Champion Julian Young/Ruth Smyth Classic Champion Paul Seabrook Research Champion...
  • Theory of Knowledge - Ms. Keeler's Haunt

    Theory of Knowledge - Ms. Keeler's Haunt

    The Human Sciences. The Arts. History. Ethics. Religious Knowledge Systems. Indigenous Knowledge Systems. You will study six of the eight. Topic. Take five minutes. Describe the smells, sounds, and tastes of Thanksgiving dinner. Be specific and sensory. ... Theory of...
  • Welcome to our worship! 29 Aug 2010 Church of Christ

    Welcome to our worship! 29 Aug 2010 Church of Christ

    Pat Davis or Sis. Karla Hardy today. Youth: $30.00 to cover one night in the hotel room will be due Sunday, March 20. Lads to Leaders/ Leaderettes. Lads to Leaders/Leaderettes. ... Valued Acer Customer Company:
  • NTC - American Public Transportation Association

    NTC - American Public Transportation Association

    Linguistic isolation is dependent on the English-speaking ability of all adults in a household. A household is linguistically isolated if all adults speak a language other than English and none speaks English "very well." Adult is defined as age 14...


    TOUR OF BEDFORMS IN RIVERS: ANTIDUNES Trains of surface waves indicating the presence of antidunes in braided channels of the tailings basin of the Hibbing Taconite Mine, Minnesota, USA. Flow is from top to bottom. Antidunes occur in rivers with...
  • Dr. Rasheen Booker

    Dr. Rasheen Booker

    My Philosophy . Through the systematic development of programs/safety nets, consistent data analysis processes, standards based instruction encompassing the implementation of proven researched based instructional strategies, ensuring literacy is a focus across all disciplines, integrating technology, and building critical thinkers...
  • Embedding SMSC in Schools - AMS UK

    Embedding SMSC in Schools - AMS UK

    A school of Character …is committed to developing moral, civic, performance and intellectual virtues in all that it does…has a stated vision for character education actively promoted throughout the school…provides all students with tangible opportunities to develop their character…is intentional,...
  • The English Sonnet

    The English Sonnet

    Listen to/Read Shakespeare's "Sonnet " Grab a partner and… Annotate the poem for rhyme scheme. What do you notice about the poem's rhythm? What do you notice about the syllables in each line? What do you notice about punctuation? How...