2.1.5 Thinking Concurrently Flashcards
1
Q
What is Concurrent Thinking
A
- Refers to systems where computatations can be executed simultaneously
- Quickly process massive data
- Concurrent systems are incredibly complex - huge increase in processing speeds.
- Recognising what parts of a problem can be solved at the same time.
2
Q
What is a Thread
A
- A thread is a small task running within a process
- A process can be made up of multiple threads
- Concurrency simultaneously running multiple threads within a single process rather than executing multiple processes at the same time
3
Q
What are the advantages of Concurrent Execution
A
- The advantages of concurrent execution are clear - can do 2 things at once.
4
Q
What are the disadvantages of concurrent execution?
A
- Deadlock
- Starvation
- Race Conditions
5
Q
What is deadlock?
A
- When every process is waiting for another to finish which is waiting for another to finish therefore no process is able to complete.
- Often cyclic, process A is waiting for process B which is waiting for C and is waiting for A.
6
Q
What are the 4 conditions that must combine simultaneously for there to be deadlock?
A
- Resources cant be shared - a printer can only be used by 1 process at a time
- A process can hold 1 resource while requesting another
- A resource can only be made available by the process currently holding it
- Circular waiting can occur
7
Q
What is starvation?
A
- When a process is denied the resources it needs.
- The process never gets enough CPU time to run
8
Q
What are Race Conditions?
A
- When 2 processes use the same memory location and the final result depends on the order in which the processes are run
9
Q
How do you identify which parts of a problem cam be executed at the same time?
A
- The 2 tasks must be completely independent of one another - any one process must not depend on the state of another if they are to be carried out simultaneously
- Secondly, conditions that will lead to deadlock, starvation and race conditions must be identified and avoided - easiest way to do this is to identify which area of the process can be solved separately without the need of resource
- Can use flowcharts