Please enable JavaScript.
Coggle requires JavaScript to display documents.
2.1.5 Thinking Concurrently - Coggle Diagram
2.1.5 Thinking Concurrently
Concurrent Thinking
Concurrent
means happening at the
same time
Concurrent execution refers to systems where the
computations
can be executed
simultaneously
Idea is more important as we deal with larger and larger sets
Disadv. of Concurrent Execution
Race conditions
- occurs when 2 processes use
same memory location
+ final result depends on order processes are run
Coffman 4 Conditions
1. mutual exclusion:
at least 1 process held in non-sharable mode
2. hold and wait
: must be process holding one resource while waiting for another
3. No pre-emption
: resources cannot be pre-empted
4. circular wait
: there must exist a set of processes
Expensive Resources
- Running programs concurrently need
extra CPUs
or
multiple cores CPUs
,
more RAM
+
faster input/output devices
. Lead to
expensive servers
of high spec to run programs w/ high level of concurrency
Deadlock
- Occurs when every process is
waiting
for another to finish; no process is ever able to complete
Starvation
- occurs when a process is always
denied
the resources it needs. If other process has priority
Threads
Is a
small task
running in a process - Processes normally made up of
multiple threads
When we talk about concurrency, talking about
simultaneous running
of multiple threads - not running of multiple process at the same time
Identify which part of a problem can be executed simultaneously
Before
threads
can be processed concurrently, 1st identify parts of problem that can be tackled
simultaneously
For 2 parts of a problem to be
executed
at same time they must be totally
independent
of one another
Secondly,
conditions
leading to deadlock, starvation and race conditions need
identified + avoided
- Easiest way is identify areas of process that can be solved separately w/ no need for a
resource
to be used by other processes at same time
A good way to plan this is through
flowcharts