{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}


14-multithreading1 - Overview CMSC 330 Organization of...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
1 CMSC 330: Organization of Programming Languages Multithreaded Programming Patterns in Java CMSC 330 2 Overview Introduction Java threads review Topics from CMSC 132 Producer / consumer pattern Conditions wait( ) notifyAll( ) CMSC 330 3 Multiprocessors Description Multiple processing units ( multiprocessor ) From single microprocessor to large compute clusters Can perform multiple tasks in parallel simultaneously 106K processor IBM BlueGene/L 32 processor Pentium Xeon Intel Core 2 Quad 6600 CMSC 330 4 Concurrency Important & pervasive topic in CS Currently covered in CMSC 132 – object-oriented programming II ° Java threads, data races, synchronization CMSC 313 – low level programming / computer systems ° C pthreads CMSC 411/430 – architectures / compilers ° Instruction level parallelism CMSC 412 – operating systems ° Concurrent processes CMSC 424 – database design ° Concurrent transactions CMSC 433 – programming language technologies ° Advanced synchronization CMSC 451 – algorithms ° Parallel algorithms CMSC 330 5 Computation Abstractions CPU 1 CPU 2 p3 p1 p2 p4 t1 t2 t1 t2 t3 t1 t4 t5 CMSC 330 6 Processes vs. Threads int x; foo() { …x… } int x; foo() { …x… } int x; foo() { …x… } foo() { …x… }
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
2 CMSC 330 7 So, What Is a Thread? Conceptually Parallel computation occurring within a process Implementation view A program counter and a stack Heap and static area are shared among all threads All programs have at least one thread (main) CMSC 330 8 Implementation View Per-thread stack and instruction pointer Saved in memory when thread suspended Put in hardware esp/eip when thread resumes eip eip eip esp esp esp esp eip stack pointer program counter CMSC 330 9 Programming Threads Thread creation is inexpensive Threads reside on same physical processor Threads share memory, resources Except for local thread variables Shared-memory programming paradigm Threads communicate via shared data Synchronization used to avoid data races Limited scalability (10’s of threads) CMSC 330 10 Programming Processes Process creation is expensive Request to operating system Processes may reside on separate processors Processes do not share memory Message-passing programming paradigm Messages using I/O streams, sockets, network, files Processes must cooperate to communicate Actions performed to send and receive data Highly scalable (1000’s of processors) CMSC 330 11 Programming Languages & Threads Threads are available in many languages C, C++, Java, Ruby, OCaml… In older languages (e.g., C and C++), threads
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 6

14-multithreading1 - Overview CMSC 330 Organization of...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon bookmark
Ask a homework question - tutors are online