Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Library (computing) wikipedia , lookup
C Sharp (programming language) wikipedia , lookup
Java performance wikipedia , lookup
Parallel computing wikipedia , lookup
Multi-core processor wikipedia , lookup
Stream processing wikipedia , lookup
Scheduling (computing) wikipedia , lookup
Chapter 4: Multithreaded Programming Operating System Concepts – 9th Edition Silberschatz, Galvin and Gagne ©2013 Multicore Programming n Multicore or multiprocessor systems putting pressure on programmers, challenges include: l Dividing activities l Balance l Data splitting l Data dependency l Testing and debugging n Parallelism implies a system can perform more than one task simultaneously n Concurrency supports more than one task making progress l n n Single processor / core, scheduler providing concurrency Types of parallelism l Data parallelism – distributes subsets of the same data across multiple cores, same operation on each l Task parallelism – distributing threads across cores, each thread performing unique operation As # of threads grows, so does architectural support for threading l CPUs have cores as well as hardware threads l Consider Oracle SPARC T4 with 8 cores, and 8 hardware threads per core Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013 Multithreading Models n Many-to-One n One-to-One n Many-to-Many Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013 Many-to-One n Many user-level threads mapped to single kernel thread n One thread blocking causes all to block n Multiple threads may not run in parallel on muticore system because only one may be in kernel at a time n Few systems currently use this model n Examples: l Solaris Green Threads l GNU Portable Threads Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013 One-to-One n Each user-level thread maps to kernel thread n Creating a user-level thread creates a kernel thread n More concurrency than many-to-one n Number of threads per process sometimes restricted due to overhead n Examples l Windows NT/XP/2000 l Linux l Solaris 9 and later Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013 Many-to-Many Model n Allows many user level threads to be mapped to many kernel threads n Allows the operating system to create a sufficient number of kernel threads n Solaris prior to version 9 n Windows NT/2000 with the ThreadFiber package Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013 Pthreads n May be provided either as user-level or kernel-level n A POSIX standard (IEEE 1003.1c) API for thread creation and synchronization n Specification, not implementation n API specifies behavior of the thread library, implementation is up to development of the library n Common in UNIX operating systems (Solaris, Linux, Mac OS X) Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013 Java Threads n Java threads are managed by the JVM n Typically implemented using the threads model provided by underlying OS n Java threads may be created by: l Extending Thread class l Implementing the Runnable interface Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013 Implicit Threading n Growing in popularity as numbers of threads increase, program correctness more difficult with explicit threads n Creation and management of threads done by compilers and run-time libraries rather than programmers n Three methods explored n l Thread Pools l OpenMP l Grand Central Dispatch Other methods include Microsoft Threading Building Blocks (TBB), java.util.concurrent package Operating System Concepts – 9th Edition 4.* Silberschatz, Galvin and Gagne ©2013