ch.3 Flashcards
concurrency
what is the difference between concurrency and parallel processing
- concurrency: the ability to handle multiple activities simultaneously
- parallel processing: the ability to handle multiple activities concurrently. aims to shorten the completion time
what all concurrent activities should have and why it’s important?
- All concurrent activities should have coordination and it’s very important because without it it could lead to deadlocks
- they should have communication because that leads to enhancing the overall efficiency of the concurrent activities
give an example of a coordination (synchronization) problem.
Dining Philosophers problem
explain dining philosophers’ problem
- Five philosophers want to eat on a table
- Only five chopsticks are available on the table
- Each philosopher needs two chopsticks to be able to eat
- Without synchronization could lead to deadlock
what is the solution to the dining philosophers’ problem?
the solution is Dijkstra’s solution which is:
* assign the resources by order
* each philosopher will request chopsticks with an order
* philosophers will request the lower-numbered chopstick first and cannot order two at the same time
This solution avoids starvation
what is the speed-up in concurrency in the cloud
through concurrent execution to overcome the physical limitations of one computer so the process is divided into multiple processes to speed up the process
what are the two sides of concurrency
- algorithmic or logical concurrency
- physical concurrency
For example: a compiler can optimize a sequential program, but a processor core can execute many programs concurrently
What is barrier synchronization?
when concurrently running tasks cannot continue to the next stage until all tasks finished
What do you know about?
communication and computation
- communication is much slower than computation
- intensive communication can drastically slow the computation of concurrent threads of applications
what is the difference between coarse-grained and fine-grained parallelism?
- coarse-grained: execute large blocks of code before communication
- fine-grained: execute small blocks of code before communication
Fine-grained is not suitable for the cloud because it will slow it
what is the difference between data parallelism and task parallelism?
- Data parallelism: data is distributed across different concurrent activities.
- Task parallelism: tasks are distributed across multiple processors.
what is the difference between data-flow and control-flow
data-flow: threads start execution as soon as their input becomes available
what is better data-flow or control-flow and why?
data-flow is better because the word is divided automatically. and the execution also starts automatically when inputs are available. So, it’s better because it can have the highest benefit from concurrency
What do you know about?
BSP bulk synchronous parallel model
- it manages the concurrent activities
- it makes parameter tuning on every physical constraint
- free the programmer from focusing on details and focus on the big picture and uses parallel slackness: add small tasks for each process until all finishes
what are the model components of BSP?
- processing units and memory
- router: for messaging between components
- synchronization mechanisms acting every L units of time