Friday, May 21, 2021

Multi thread and Concurrency - Questions

Q1.Why do we want to use multiple threads in an application?


  1. The more threads in one application, the faster the application will be.
  2. By using multiple threads we can execute multiple related tasks simultaneously, making the application more responsive. And executing multiple tasks in parallel may achieve higher performance.
  3. Having multiple threads is always a better software design.
  4.  Creating more threads in one process, is always better than creating a new application.


Q2. Multiple threads in a single process share:


  1. The stack , heap , instruction pointer, Code,  The process's open files
  2. Only application code
  3. The heap, Code, The process's open files, The process's meta data
  4. Only heap


Q3. How does the Operating System design what thread to schedule?

  1. The Operating System maintains a dynamic priority for each thread to prioritize interactive threads and to avoid starvation for any particular thread in the system.
  2. The Operating System is going to choose the interactive threads ahead of any other threads at all times to make the users happy.
  3. The Operating System will always pick the shortest job at any given moment.
  4. The Operating System will simply pick a random thread to execute, which on average will be fair to everybody.

 

Q1 - 2

Q2 - 3

Q3 - 1

No comments:

Post a Comment