in reply to Re: Critical section FCFS
in thread Critical section FCFS

Crit.pl is one thread program. It may be called simultaneously, as you mentioned I need to serialize access.

Example: Call1 to crit.pl - running Call2 - waiting for lock Call3 - waiting for lock ..

In this case call2 should execute after call1 completes, followed by call3.

Can you please explain more on how shared variable can be used for this?

Replies are listed 'Best First'.
Re^3: Critical section FCFS
by Anonymous Monk on Jul 14, 2016 at 04:13 UTC

    The FCFS stands for "first-come, first-served"? And you intend the script "crit.pl" to both queue up and serve the requests as well? Technically, your calls (processes) will then be executing at the same time, though only one can have the critical section.

      Apologies for the confusion.

      1. FCFS - First come first serve

      2. Rewriting the example

      Critical section= CS
      Example: Call1 to crit.pl - running CS Call2 to crit.pl- waiting for lock on CS Call3 to crit.pl- waiting for lock on CS
      Lets say the CS writes timestamp entry to the file . Following events

      Time1:Call1 is running CS, Call2 is waiting for acquiring lock on CS.

      Time2: Call1 is still running, call 2 waiting for the lock on CS+ a new call3 is also waiting for the lock on CS

      Time3 : call1 complete. Call2 acquires lock on CS. Call3 waits

      Time4: call2 complete. Call3 acquires lock

      Basically want the critical section to execute in the same order of call.

      The order of time stamps in critical section should always be in ascending order . Hope this makes it clearer.

      Apologies for the confusion.

      1. FCFS = first come first serve

      2. Re-framing the example

      Critical section = CS lets say the CS is writing time-stamp (of when crit.pl is called) to file.

      Example: Call1 to crit.pl - running CS Call2 to crit.pl - waiting for lock on CS Call3 to crit.pl - waiting for lock on CS

      Time wise events

      T1: Call1 locks CS, Call2 waits for the lock on CS

      T2: Call1 still has lock on CS, Call2 waits + new Call3 arrives and also waits

      T3: Call1 completes, Call2 acquires lock on CS, Call3 waits

      T4: Call2 completes, Call3 acquires lock on CS

      The CS time stamps should be ascending order

      Hope this makes it clearer. Please let know if this can be achieved. Thank you

        May I ask, what is the purpose of multi-tasking * the overall processing, if you are going to then seek some complicated mechanism to force them to run serially?


        With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
        In the absence of evidence, opinion is indistinguishable from prejudice.