I am wondering whether timestamp can be used to solve process synchronization problem, when race condition occurs?
Below is an algorithm for entry as well as exit sections for every process who wants to enter in critical section. Entry section uses FCFS (First Come First Serve) technique to give access to critical section.

    interested[N] is shared array of N integers where N is number of processes.

    // This section executed when process enters critical section.
    entry_section (int processNumber) {
        interested [processNumber] = getCurrentTimeStamp ();  // Gets the current timestamp.
        index = findOldestProcessNumber (interested);         // Find the process number with least timestamp.
        while (index != processNumber);

    // This section executed when process leaves critical section.
    exit_section (int processNumber) {
        interested [processNumber] = NULL;

According to me, this algorithm satisfies all conditions for synchronization, i.e., Mutual Exclusion, Progress, Bounded waiting and Portability. So, Am I correct?

Thanks for giving your time.


1 Answer 1


The short answer is yes, since what you're essentially doing with the timestamps is making all potentially conflicting processes sequential. Of course, in sequential systems there are no race conditions (a bit of a simplification, but nevertheless). In what way does timestamping processes differ from creating locks on resources, which is the current standard in parallel computation? You may want to reflect on what the real issues with race conditions are. Maybe this definition from Wikipedia might help:

"A race condition or race hazard is the condition of an electronics, software, or other system where the system's substantive behavior is dependent on the sequence or timing of other uncontrollable events."

So the primary issue to consider is what happens when you don't have control over the process(es) that cause(s) the race condition.

  • $\begingroup$ Thank you @DeBunkeD. Kindly have a look at the second question, i.e., whether above algo satisfies all conditions for synchronization (Mutual Exclusion, Progress, Bounded wait). $\endgroup$
    – Shiv
    Nov 28, 2019 at 18:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.