14_f09_Multithreading - Multithreading A Process A Process...

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

View Full Document Right Arrow Icon
Multithreading A Process • A Process is a running application • A Process is composed of Threads – e.g. a process may have: • A GUI thread • Several computational threads • A file I/O thread • A print thread
Background image of page 1

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

View Full DocumentRight Arrow Icon
Multithreading •Thread –A block of code that is the fundamental unit of execution to which processor allocates processor time –Threads run concurrently and share the cpu(s) •OS manages running threads with scheduling algorithms •Switches processor time between threads •Done so fast and efficiently that it appears all threads are running simultaneously –A .NET managed application begins as a single thread •Can spawn additional threads to partition its tasks –On multi-cpu system, applications can run faster since different threads can run on different processors Concurrent Execution •Threads run concurrently and asynchronously with respect to each other •Example: a GUI application that enters into a long computational loop –Running as a single thread: •While application’s single thread is computing, messages on the message queue are ignored –So the application’s user interface is frozen until computation finishes –Running as two threads: •Relegate the computational work to a background thread •Now the primary thread is free to service the message queue –App is now responsive to user input while computation is occurring
Background image of page 2
Multithreading Complexities •Since threads run asynchronously, multithreaded –For example, write then read a data structure •If both are in a single thread, we know write will occur first
Background image of page 3

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

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 7

14_f09_Multithreading - Multithreading A Process A Process...

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

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