Computational Thinking: Thinking Concurrently
Computational Thinking: Thinking Concurrently
-
Concurrent thinking facilitates multiple tasks occurring side by side rather than sequentially. This shift from linear thinking can enable systems to operate more efficiently.
-
This approach is akin to multitasking. In a concurrent thinking model, various tasks are fragmented into subtasks that are then solved simultaneously or in parallel.
-
Parallelism and concurrency, while related, are not the same. Parallelism is the simultaneous execution of (possibly related) computations, while concurrency is the composition of independently executing processes.
-
Synchronous and asynchronous processing are two important concepts in concurrent thinking. Synchronous refers to tasks that are dependent on each other in the order of execution, while asynchronous tasks are independent and can be executed in any order.
-
Threading is an application of concurrent thinking. Threads are smaller units of a process which can run concurrently, enabling simultaneous execution of different parts of the programme.
-
Deadlocks and live locks are two possible issues in concurrent processes. Both describe situations where process executions are halted due to circular dependencies and it’s important to understand methods for avoiding these situations.
-
In concurrent thinking, use of shared resources can lead to race conditions, where the output is dependent on the sequence or timing of uncontrollable events. Strategies to avoid race conditions include using atomic operations, locks, or semaphores.
-
Recognize that synchronisation processes like locks, semaphores, monitors and barriers are necessary in some concurrent models to avoid problems like race conditions and to coordinate the process of execution among threads.
-
Learn to apply various models and techniques such as mutual exclusion, process synchronisation, thread scheduling, and inter-process communication to handle tasks in concurrent programming effectively.
-
Appreciate that choosing to use a concurrent model can impact a system’s speed, complexity, and resources. It might not always be the best approach if, for example, tasks are not independent or the overhead of managing multiple threads outweighs the potential speed gain.
-
Understanding concurrent thinking is integral to the effective design and coding of algorithms and programmes that need to process vast amounts of data or are required to be highly responsive.