What is a Computer Program?
A computer program is a sequence instructions that when performed in a computer carry out a particular task. There are two ways to run a program in a computer.
Sequential Processing
The instructions are performed one after the other using the computer. The program is stored in the memory and instructions are fetched one by one and executed within the CPU.
Example:
Input A
Input B
Total = A+B
Print Total
Concurrent Processing
The instructions are performed in parallel within the computer. This may be done using multiple processors or using the same processor with time sharing. This type of concurrent processing increases the efficiency and more common in networked environments.
Example:
Thread 1:
Input A
Input B
Total = A+B
Print Total
Thread 2:
Read C,D
Total = Total + C + D
Print Total
In this situation Thread 1 and Thread 2 process at the same time. The processor no need to wait until the thread 1 finished to start thread 2.
No comments:
Post a Comment