In: Computer Science
What is
A- Atomic Action
B- Critical Section .
in OS
in your own words with examples.
A) Atomic Action
Atomic operations in concurrent programming are program
operations that run completely independently of any other
processes.
Atomic operations are used in many modern operating systems and
parallel processing systems.
Atomic operations are often used in the kernel, the primary
component of most operating systems. However, most computer
hardware, compilers and libraries also provide varying levels of
atomic operations.
In loading and storing, computer hardware carries out writing and
reading to a word-sized memory. To fetch, add or subtract, value
augmentation takes place through atomic operations. During an
atomic operation, a processor can read and write a location during
the same data transmission. In this way, another input/output
mechanism or processor cannot perform memory reading or writing
tasks until the atomic operation has finished.
Where data is being used by an atomic operation that is also in use
by other atomic or non-atomic operations, it can only exist in
either sequential processing environments or locking mechanisms
have to be used to avoid data errors. Compare and swap is another
method but does not guarantee data integrity for atomic operation
results.
The problem comes when two operations running in parallel
(concurrent operations) utilise the same data and a disparity
between the results of the operations occurs. Locking locks
variable data and forces sequential operation of atomic processes
that utilize the same data or affect it in some way.
B) Critical section
The critical section is a code segment where the shared variables can be accessed. An atomic action is required in a critical section i.e. only one process can execute in its critical section at a time. All the other processes have to wait to execute in their critical sections.
A diagram that demonstrates the critical section is as follows −
In the above diagram, the entry section handles the entry into the critical section. It acquires the resources needed for execution by the process. The exit section handles the exit from the critical section. It releases the resources and also informs the other processes that the critical section is free.
Solution to the Critical Section Problem
The critical section problem needs a solution to synchronize the different processes. The solution to the critical section problem must satisfy the following conditions −
Mutual exclusion implies that only one process can be inside the critical section at any time. If any other processes require the critical section, they must wait until it is free.
Progress means that if a process is not using the critical section, then it should not stop any other process from accessing it. In other words, any process can enter a critical section if it is free.
Bounded waiting means that each process must have a limited waiting time. Itt should not wait endlessly to access the critical section.
Note: Plzzz don' t give dislike.....Plzzz comment if u have any problem i will try to resolve it.......