2.1.5 - Thinking Concurrently Flashcards

1
Q

What is concurrency?

A

An application is making progress on more than one task at the same time (concurrently).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is concurrent processing?

A

Concurrent processing means different tasks are given slices of processor time, to give the illusion that tasks are being performed simultaneously.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is meant by thinking concurrently?

A

Thinking concurrently is a skill which involves working out which parts of a program can be developed to take place/be processed at the same time. You must consider which parts are dependent on others (these can’t be done concurrently).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Benefit of concurrent programming

A
  • Number of tasks completed in a given time is increased.
  • Less time is wasted waiting for an input/user interaction as other tasks can be completed.
  • A user can interact with applications whilst other tasks are running in the background e.g. working on a presentation whilst downloading a file.
  • A long-running task won’t delay short-running tasks e.g. text loading before images on a web page.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Drawbacks of concurrent processing

A
  • Concurrent processing can take longer to complete when large numbers of users or tasks are involved as processes cannot be completed at once.
  • There is an overhead in coordinating and switching between processes, which reduces program throughput.
  • Just as with parallel processing, not all tasks are suited to being broken up and performed concurrently.
  • Tasks can suspend and wait on each other indefinitely (known as deadlock).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is parallelism?

A

Parallelism means that an application splits its tasks into smaller subtasks which can be processed in parallel, e.g. over multiple CPU cores at the exact same time.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Benefits of parallel processing

A
  • Parallel processors enable several tasks to be performed simultaneously by different processors. It can speed up processing when repetitive calculations need to be performed on large amounts of data.
  • Graphics processors can quickly render a 3D object by working simultaneously on individual components of the graphic.
  • A browser can display several web pages in separate windows and one processor may be carrying out a lengthy search or query while processing continues in other windows.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Drawbacks of parallel processing

A
  • There is an overheard in coordinating the processors
  • Some tasks may run faster with a single processor than with multiple processors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

A flight simulator allows a user to take control of a simulated aeroplane. The user can fly the plane in an environment that can simulate different weather conditions and additional planes in the sky.

Explain what is meant by ‘concurrent processing’ and describe one example of how the simulator could make use of it. (4)

A

Concurrent Processing:
One process does not have to finish before the other starts (1)

Example:
Each plane can move independently (1)
All move at the same time (1)
All need to react to different events (1)

The weather (1)
Wind, rain, direction of air etc. (1)
Each element needs to be run simultaneously (1)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

A programmer is developing an ordering system for a fast food restaurant. When a member of staff inputs an order, it is added to a linked list for completion by the chefs.

The programmer is considering using concurrent programming.

Discuss how concurrent programming can be applied to the food ordering system and the benefits and limitations of doing so. (9)

A

AO1:
● Processes are happening at the same time / at overlapping times
● Only 1 process can actually happen at a time on a single core processor, concurrent tries to simulate multiple processes
● One process may need to start before a second has finished
● Individual processes are threads, each thread has a life line

AO2:
● Multiple orders can be made and added to the list at the same time
● Programming will need to allow multiple threads to manipulate a single list
● Will allow those reading and writing to manipulate at the same time
● Locking will need implementing – more complex programming

AO3:
● Will allow for multiple orders at the same time – as it would happen in real life
● Access to the linked list will need to be limited so it cannot be accessed / overwritten by two threads trying to do different operations
● Not all of the process will be paralleliseable. X processors does not mean it will run in 1/xth of the time of one processor.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly