Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Critical section FCFS

by Anonymous Monk
on Jul 13, 2016 at 19:44 UTC ( [id://1167726]=note: print w/replies, xml ) Need Help??


in reply to Critical section FCFS

What do you mean by "calls it first"? Programs run in parallel under multi-processor setups. The calls may be simultaneous.

Do you have one threaded program that needs to serialize its accesses? Or is it multiple programs that need to cooperate? (In the first case, just lock a shared variable and that's it.)

Replies are listed 'Best First'.
Re^2: Critical section FCFS
by Anonymous Monk on Jul 14, 2016 at 02:44 UTC

    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?

      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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1167726]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-04-24 20:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found