Wednesday, April 10, 2019

Why Multithreading

Why Multithreading? My previous post was more about what is multithreading and we contrasted that with what is multitasking.

Most of the hardware in use today be it processors in servers, laptops or those in mobile phones are all equipped with multicore processors. It is only natural to expect then that software written to run on these devices make full use of the hardware and it capabilities. Shouldn’t the performance gains be double if the same tasks which was earlier running on a single core processor is now running on a dual core processor? Actually in practice this is not the case. Extracting good performance out of a dual core processor needs programmer intervention. It is not something that happens automagically. This is explored clearly in this article in Dr. Dobbs journal “The Free Lunch Is Over: A Fundamental Turn Toward Concurrency in Software” by Herb Sutter that appeared in Mar 2005. I have provided a link to the republished article.

Sunday, April 7, 2019

Overview of Multithreading

Multithreading is the ability to run multiple threads in a program at the same time. A thread is the smallest unit of execution for the purposes of this discussion. A larger unit of execution than threads that one should be aware of is a task from which stems the word Multitasking. Tasks are also termed processes. We could call this multiprocessing at the OS level, but this word is also used to refer to hardware supporting multiple processors. The often confusing terms such as 'Parallel', 'Concurrent', and 'Synchronous' are related to Multithreading and Multitasking.

Knotted Threads

Photo by Francesco Ungaro from Pexels