Содержание
- 2. What is the Multithreading? An ability that allows you to run several sections of code simultaneously.
- 3. >So, why does modern OS supports threads? Because with this approach ‘RESET’ button is pressed less
- 4. Process Executing instance of a program. Virtual memory and no direct communication. Threads container Thread Basic
- 5. Thread in numbers Kernel State (Kernel Object) 700 bytes for x86 1240 bytes for x64 Thread
- 6. Hardware trends CPU development: Single-core Multi-socket motherboards Single-core with Hyper-threading Multi-core Multi-core with Hyper-threading
- 7. Context switches Kernel-level scheduler responsibility Schedule applies to threads, not to processes Relies on the priority
- 8. Process and Thread Priority Relations
- 9. Where should I use Threads? Client-side GUI applications where responsiveness is important. Client-side and server-side applications
- 10. Thread usage example.
- 11. Briefly about Thread class Return type is void Constructors: - Thread(ThreadStart) - Thread(ParameterizedThreadStart) - Thread(ThreadStart, Int32)
- 12. Producer/Consumer Pattern BlockingCollection as queue Variable number of producer/consumer threads
- 13. P/C Pattern implementation public class Producer : IDisposable { private volatile bool _isRunning; private Thread _commandGetThread;
- 14. CLR ThreadPool Class ThreadPool was introduced in .Net Framework 3.5. Later, Task approach will use it
- 15. What is ideal thread number? How queues are scheduled? What is Work-Stealing? How CLR manages thread
- 16. Thread Pool usage example.
- 17. Tasks concept Return value from asynchronous operation. Just call task.Result You know, when operation completes Task
- 18. Tasks states *Also, task can be in waiting (for activation, to run, for children’s completion) states
- 19. Waiting task.Wait() instead of while(!task.IsCompleted) Task.WaitAny() for response processing with best performance Task.WaitAll() if you need
- 20. Continuations In order to write scalable software, you must not have your threads block. Calling task.Wait()
- 21. Factories To create a bunch of tasks that return void, then you will construct a TaskFactory.
- 22. To simplify writing code for parallel execution, there are: The Parallel class Parallel.For(fromInclusive, toConclusive, index =>
- 23. Also, there is possibilty in TPL that allows interaction among parallel parts of algorythm. Use localInit
- 24. Not every algorithm could be parallel
- 25. PLINQ Parallel Language Integrated Query – set of extensions that allows parallel processing of ParallelQuery collection.
- 26. Parallel and PLINQ usage example.
- 27. Allows you to perform a Periodic Compute-Bound Operation. Timers System.Threading.Timer usage example To many timers in
- 28. Object should have GetAwaiter() method implemented to be available for await Async method without awaits inside
- 29. Async/Await example.
- 30. Asynchronous Programming Model (APM) Event-based Asynchronous Pattern (EAP) Task-based Asynchronous Pattern (TAP) Asynchronous Programming Patterns APM
- 31. Inspired by Technology. Driven by Value.
- 33. Скачать презентацию