Friday, April 22, 2011

Basics on motivation towards Parallelism


“My desktop/laptop is not responding well” is one of the common thoughts that would have occurred with most of the computer users. But computers have come long away from few Hz processors to GHz processors [Hertz (Hz) of a processor is one of the major factor which affects the speed/responsiveness of the computer]; still we live unsatisfied when it comes to responsiveness of the computers.

Then why not the processor manufacturers can increase the frequency [measured in Hz] of the processor to improve the responsiveness of the computer?

Following are some of the reasons for limited frequency in processors:
  1. Unfortunately frequency of the processor is directly proportional to the power consumption by the processor.
  2. When more power is consumed lot of heat will be dissipated, we need a proper cooling mechanism to overcome the excessive heat energy generated at processor. Nowadays with laptops there is only 3 inches of window which is used for air cooling :)

In what other ways the speed of the processor can be improved?

Processor performance can be improved by executing the programs [any application that runs in your computer, for example solitaire game, internet explorer browser] in parallel. 

Okay, what is parallel execution?
The parallel execution is all about executing more than one task at a given point of time by the computer. Normally, computers might have single processor; nowadays modern day computer comes with muti-core processors or more than one processor in a computer. Okay when we have more than one processor, it is logical to think about performing more than one task at a given point of time, but how come the parallelism in single processor are achieved; it’s through multiprocessing and multithreading [a pseudo parallelism technique].

Parallelism in single processor
Multiprocessing is like running more than one process at same time. This is like running the browser [internet explorer, firefox, chrome, etc.,] and games [solitaire, Minesweeper, etc.,] concurrently. One can view the n number of process running in the windows operating system through Task Manager [Press Ctrl + Shift + Esc].

Multithreading is achieved with in a process. For example, one can download movie and watch the movie simultaneously. There are two tasks involved; one is downloading the movie from internet and the other task is playing it in windows media player. There is only one processor available, then how can one processor perform more than one action at same time. Consider an analogy to this activity like reading a book and rewriting the book in another diary. How one can do both reading and rewriting at the same time; either one can read or write at a given point of time. But, it can be achieved by reading one line from the book and writing it to another diary. If both the activities are done at a rate in which both reading and writing are undistinguishable.

Similarly, the processor downloads few bytes of movie and plays it for few seconds, this activity is repeated until entire movie is downloaded and played. The processor switch between movie download and playing the movie happens in such a way that user feels that both are occurring simultaneously. This is a kind of pseudo parallelism, where one task is happening at a given point of time, but it makes us feel like both of them are happening concurrently.

Parallelism in multi-core processor [Single Processor]
A single processor can have multiple cores; each core can execute the tasks independently. Tasks can be run in different cores to improve the performance, provided that both of them are independent. Going back to the example on running browser and games concurrently, browser can be run on core 1 and game on core 2 because both of them are independent. But if there are two tasks that are dependent on each other, they cannot be run in different cores, atleast some of the components of the programs which are closley coupled.

So, the motivation towards parallelism is to make the computer faster which is nothing but the relentless thoughts of humans to run faster and faster.

No comments:

Post a Comment