Logout

--- Thinking concurrently ---

4.1.14

Identify the parts of a solution that could be implemented concurrently.

 

Teaching Note:

Could include computer systems or real-life situations.

LINK Thinking ahead, thinking procedurally. Connecting computational thinking and program design, introduction to programming.

 

Sample Question:

From Sample Paper 1 2014:

sample question

 

JSR Notes:

The Basics of Concurrency

Concurrency describes a situation in which more than one thing can happen concurrently, i.e. more than one thing can happen at the same time.

So, for example, you can pat your head and rub your stomach at the same time (maybe...). A person can drive a golf cart and chew gum at the same time. And so on. When two or more things can happen a the same time, this is concurrency.

In terms of computers, concurrency is the ability of the software and hardware of a computer to process two or more things at the same time. With regard to the program being run, two things can only happen at the same time if neither depends on the other being finished first. And with regard to the computer hardware, it needs to have been designed with the capacity to do concurrent processing


Non-Computer Examples

GANTT Chart Project

Here the GANTT chart we already looked at is a useful illustration/tool, since you can clearly see from its structure the sub-tasks which can happen at the same time; they overlap horizontally on the chart.:

GANTT Chart

 

The Building a House Example


In the constructing a house example at the top of this page, the following could all be done concurrently:

But the following cannot be done concurrently; they must be done in the order listed:

 

 

Computer/Programming/Java Examples


Terms associated with computer concurrent processing:

Concurrent processing - more than one thing actually being processed at once.

A single-core CPU actually only does one thing at at time, but it accomplishes very complex things by doing each individual thing in an incredibly tiny fraction of a second. A CPU might have a "clock speed" of 2 or 3 GHz - that means that it can do 2 or 3 Billion of these very small things in one second. To actually accomplish the simplest step of a program, like adding two numbers together might take a "pipeline" of 20 or so of these steps, but that still means it can do hundreds of millions of these simplest steps every second. Still, without concurrency, things would still have to progress only one step at a time.

Thread - one process of multiple concurrent processes. Think of the various "threads" of a good novel, i.e. several story-lines progressing through the novel. Or what I called the three "threads" of my old Pro IT course: IT & Me, My Laptop, and IT As a Profession; these themes were threaded through the course. Or even think of the various threads that run through a scarf from one end to the other. So in computer terms, two or more processes which proceed at the same time are called threads. In fact, in Java, you can create a thread, similarly to creating other objects.

Thread t = new Thread (this, "myFirstThread"); 

Multi-threading - the process of running, concurrently, multiple threads.

Multi-threading Environment - a software and hardware "environment" which both support multi-threading (i.e. concurrent processing).

 

Hardware-specific terms associated with concurrent processing:

Multi-core Processor - a CPU which has more than one core, and so can do concurrent processing.

Hyper-threading - this is a term for a hardware technology created by Microsoft for simulating concurrency within a single processor.

Look up hyper-threading etc. on YouTube (here's one example) to give you a view of both multi-processing across a "quad-core" processor (i.e. 4 cores), and hyper-threading with each one of them, effectively giving you the capacity of doing 8 processes all at the same time (i.e. concurrently.)

 

Example 1:

--> A video is being streamed and buffered while

--> the first part of the video (having been buffered 30 seconds ago) is being played

 

Example 2:

--> half of the frames of a 3d animation are dished out to one processor,

--> and the other half of the frames are dished out to another processor (to be rendered, i.e. strung together in good quality images, as one video).

 

Example 3:

A certain Photoshop filter

--> changes the colors of every pixel a certain way,

--> and also moves those pixels around, the odd pixels up by one, and the even pixels down by one.

 

For a good sample question on concurrency, look up question 13 of Sample Paper 1.