Categories

A sample text widget

Etiam pulvinar consectetur dolor sed malesuada. Ut convallis euismod dolor nec pretium. Nunc ut tristique massa.

Nam sodales mi vitae dolor ullamcorper et vulputate enim accumsan. Morbi orci magna, tincidunt vitae molestie nec, molestie at mi. Nulla nulla lorem, suscipit in posuere in, interdum non magna.

What is Process/Thread Synchronization?

Synchronization is a very important process in the systems which are multiprocessor or multitasking. Synchronization in itself refers to very different concepts but which are related to each other. These two different concepts are:

  • Synchronization of data
  • Synchronization of processes

– In synchronization of data, multiple copies of the set of data are created and kept in coherence with each other.
– This is also done form maintaining the integrity of the data.
– When multiple processes at a certain point do a handshake for making up an agreement or committing to some action is called process synchronization.
– The primitives of the process synchronization are used for the implementation of the data synchronization.
– Thread synchronization is also known as the serialization.
– When defined strictly, it can be thought of a process of applying certain mechanisms for ensuring that the two threads or process that are executing concurrently are not executing the same portion of the program simultaneously.
– If the first thread or process has started with the execution of some serialized part of the program, then the second thread or process requiring to execute this same part must wait till the first one is done with the execution.

– Synchronization process is extremely useful in the field of multiprocessing systems and distributed systems in multi-threaded environments, database and banking systems and so on.
– Information is produced by the producer and a consumer process consumes this process.
– A part of the code that is used by n number of cooperating processes in which common variables might be accessed by the processes.
– Following are the parts of the critical section environment:

  • Entry section: This section consists of the code that requests for entry in to the critical section.
  • Critical section:This section consists of the code that can be executed by only one process at a given time.
  • Exit section:This section is the one marking the critical section’s end. It either releases the other processes or allows them.
  • Remainder section:This section consists of all the code except that of the critical section.

For synchronization the below mentioned rules are always enforced by the critical section

  • Rule of mutual exclusion: It states more than one process cannot be executed in the critical section simultaneously.
  • Rule of progress: It states that if no process is being executed in the critical section and it is required by some process, then the processes in the waiting state must take a decision regarding who should occupy the section under a finite amount of time.
  • Rule of bounded wait: It states all the requesting processes must be admitted to the critical section.

– A flag is maintained by each of the processes and threads which give the state of that process or thread.
– The flag usually indicates that the process or the thread requires going to in to the critical section.
– Flags of all the other processes are checked if they want to go, then this process does not enter the critical section.
– The flag is set by the process to one for requesting entry in to the critical area.
– Then there is a toggle between the processes for allowing the other processes to go in first.
– The following are the requirements of the hardware that can support the critical section:

  • Indivisible instructions
  • Atomic test, load and store instruction

– In some cases, semaphores might be used for forcing the synchronization process if a signal is given by the preceding process and the succeeding process is waiting.
– Semaphores might be used either as lock managers and event counts.
– There are possibilities of deadlocks when two or more processes may try to access the same resources simultaneously. – There are many other problems associated with the process and thread synchronization such as the bounded buffer problem, the readers/ writers problem, the dining philosopher’s problem.
– With high level synchronization constructs, the safe sharing of the data types becomes easy among the processes that are executing concurrently.

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>