2.1.4 - Thinking concurrently Flashcards
concurrency
means an application is making progress on more than on task at the same time
thinking concurrently
is a skill which involves working out which parts of a program need to be developed so that they can be processed at the same time and which parts are dependent on each other
parallel processing
when multiple processors are used to complete more than one task simultaneously
parallelism
means an application splits its task into smaller subtasks which can be processed in parallel
Difference between concurrency and parallelism
- a system is said to be concurrent if it can support two or more actions in progress at the same time
- a system is said to be parallel if it can support two or more actions executing simultaneously
Concurrency is about…
dealing with lots of things at once
Parallelism is about…
doing lots of things at once
benefits of concurrent processing
reactivity
- users are able to interact with applications while other tasks are running
availability of services:
- a long running task won’t delay a short running one
parallelism:
- a complex program can make use of multi-core/ multi-processor systems
controllability:
- a task that requires preconditions to proceed can be suspended and easily resumed later on
reasons for concurrent processing
- the number of tasks completed in a given time is increased
- the time that would be wasted by the processor waiting on a user or another process is reduced
drawbacks of concurrent processing
safety
- possibility of corrupting the consistent state of a program
liveness:
- tasks can suspend and wait for each other indefinitely, known as deadlock
resource consumption:
- threads can consume resources in regards to scheduling, context-switching and synchronisation
thread
are entities within a process that can run concurrently in shared memory spaces