Threading in C#
Short Description
C# supports parallel execution of code through multithreading. A thread is an independent execution path, able to run simultaneously with other threads.
Website: www.albahari.com | Filesize: 464kb
No of Page(s): 78
Content
…Multithreading is managed internally by a thread scheduler, a function the CLR typically delegates to the operating system. A thread scheduler ensures all active threads are allocated appropriate execution time, and that threads that are waiting or blocked - for instance - on an exclusive lock, or on user input - do not consume CPU time.
On a single-processor computer, a thread scheduler performs time-slicing - rapidly switching execution between each of the active threads. This results in “choppy” behavior, such as in the very first example, where each block of a repeating X or Y character corresponds to a time-slice allocated to the thread. Under Windows XP, a time-slice is typically in the tens-ofmilliseconds region - chosen such as to be much larger than the CPU overhead in actually switching context between one thread and another (which is typically in the few-microseconds region).
On a multi-processor computer, multithreading is implemented with a mixture of time-slicing and genuine concurrency - where different threads run code simultaneously on different CPUs. It’s almost certain there will still be some time-slicing, because of the operating system’s need to service its own threads - as well as those of other applications.
…
Get the file Download here
Related Books:Related Searches: independent execution, parallel execution, execution path, different cpus, processor computer
Comments
Leave a Reply