Concurreny

Concurrency (computer) is a concept where many process or thread run simultaneously in uniprocessor or multiprocessor or multicore. Computer users take it for granted that their systems can do more than one thing at a time.Even a single application is often expected to do more than one thing at a time.

Concurrency arises in 3 different contexts:

  1. Multiple Applications: Multiprogramming was invented to allow processing time to be dynamically shared among active applications. 
  2. Structured Applications: As Extension of the principle of modular design and structured programming. 
  3. Operating system(OS) structure: OS themselves implemented as a set of processes or threads. 

Here is some of the key term use in concurrency.

Atomic Operation
Function or action implemented as a sequence of one or more instructions that appears to be indivisible; that is, no other process can see an intermediate state or interrupt the operations. The sequence of instruction is guaranteed to execute as a group, or not execute at all, having no visible effect on system state. Atomicity guarantees isolation from concurrent processes.
Critical section
A section of code within a process that requires access to shared resources and that must not be executed while another process is in a corresponding section of code.
deadlock
A situation in which 2 or more processes are unable to proceed because each is waiting for one of the others to do something.
Like stock
A situation in which 2 or more processes continuously change their states in response to changes in the other processes without doing any useful work.
Mutual exclusion
The requirement that when one process is in a critical section that accesses shared resources, no other process may be in a critical section that accesses any of those shared resources.
Race condition
A situation in which multiple threads or processes read and write a shared data item and the final result depends on the relative timing of their execution.
Starvation
A situation in which a runnable process is overlooked indefinitely by the scheduler; although it is able to proceed, it is never chosen.

Principle of concurrency 

Interleaving and overlapping can be viewed as examples of concurrent processing and both present the same problems.


Interleaving and overlapping

In case Uniprocessor,the problem stem from a basic characteristic of multiprogramming system.The relative speed of execution of process cannot be predicted because it depends on activities of other processes,The way in which the OS handles interrupts and the scheduling policies of the OS.

Difficulties of concurrency

Sharing of global resources is fraught with peril.For example, if 2 processes both make use of the same global variable and both performs reads and writes on that variable, then the order in which the various reads and writes are executed is critical.

Another difficulties is Operating system is difficult to manage the allocation of resources optimally.Besides, it becomes very difficult to locate a programming error because results are typically not deterministic and reproducible.

Comments

Post a Comment

Popular posts from this blog

Reading and Writing Operation of SRAM

Reading & Writing Operation of DRAM

Method to Convert from Stream to Json C#