Part II: 4: Threads [B1] Flashcards
What is a thread?
Represent a basic unit of CPU utilization, and threads belonging to the same process share many of the process resources including code and data.
Comprises of thread ID, a program counter, a register set, and a stack.
What are some benefits of threads?
- responsiveness
- resource sharing
- economy
- scalability
Explain single threaded vs multithreaded programming
Single threaded;
* Only one sequence of instructions the CPU executes.
* Linear, all tasks executed after one another.
* Entire program affected if one task take long to complete.
* Simpler to design and debug, but lack the ability to fully utilize multi-core processors.
Multi thread:
* Multiple threads can run concurrently
* Each thread -> independent sequence of instructions and can be executed concurrently on multiple processor cores.
* Different parts of the problem can be worked on simultaneously, improving program performance, responsiveness and resource utilization.
While single-threaded programs are often easier to develop and debug, multithreaded programs can provide improved performance by leveraging the capabilities of modern hardware
What are the relationship between threads and multicore arcitechture?
The ability to execute multiple threads simultaneously, for higher performance and responsiveness.
Name some multithreading models
Explain some issues regarding multithreaded programming.