• Peterson's Algorithm in java, sequencial instruction execution ?

    From dipanseshagiri@gmail.com@21:1/5 to Lawrence on Tue Jul 28 00:23:14 2020
    On Saturday, November 25, 2006 at 9:08:06 AM UTC+8, Lawrence wrote:
    Hello guys,

    I have to implement the Peterson's algorithm in java.
    For who of you which is not aware about it, is a low level concurrency solution for two threads
    that want to use a shared resource.
    The algorithm use three variables, two flags (booleans) and a turn
    indicator (usually implemented as an int, but possibly a boolean would
    work as well).

    More information about the algorithm here : http://en.wikipedia.org/wiki/Peterson's_algorithm

    Now, is really easy to implement it and in theory I won't need to use
    any synchronization
    construct available in java (such as synchronized keyword) since the
    shared memory should be enough.

    Here comes my problem : I learned that some hardware system don't
    necessarily execute the instructions
    in a FIFO order, such as, they don't execute necessarily instructions
    in the same order as they are written in the source code (and then
    compiled) to improve efficency.
    All this in a standard sequencial program (not concurrent).
    Such hardware, to support concurrency, has special "atomic" instrucion
    such as test & set.

    What about the jvm ?
    Because if this is the case (such as execution of the instructions not
    in a sequencial way), the instructions in my program could be executed
    in an order that is not the one I wrote it that will eventually result
    in an invalid state of the program.

    Thank you for any information.

    Hello from 2020!
    Not sure if this will reach you, but just wanted to say that this whole thread discussion is helping me out in one of my assignments 14 years down the road! :D

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Graeme Geldenhuys@21:1/5 to dipanseshagiri@gmail.com on Fri Oct 9 23:51:48 2020
    Hi,

    On 28/07/2020 8:23 am, dipanseshagiri@gmail.com wrote:
    Hello from 2020! Not sure if this will reach you, but just wanted
    to say that this whole thread discussion is helping me out in one
    of my assignments 14 years down the road! :D

    I'm not the original poster, but am curious while news server you
    are using that still has message from to long ago. I'm using a
    pretty rubbish one where messages expire in something like 14 days.
    Makes reading long discussions or past thread impossible. :-/
    I'm hoping to find a better news feed.

    Regards,
    Graeme

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Richard Damon@21:1/5 to Graeme Geldenhuys on Fri Oct 9 20:18:54 2020
    On 10/9/20 6:51 PM, Graeme Geldenhuys wrote:
    Hi,

    On 28/07/2020 8:23 am, dipanseshagiri@gmail.com wrote:
    Hello from 2020! Not sure if this will reach you, but just wanted
    to say that this whole thread discussion is helping me out in one
    of my assignments 14 years down the road! :D

    I'm not the original poster, but am curious while news server you
    are using that still has message from to long ago. I'm using a
    pretty rubbish one where messages expire in something like 14 days.
    Makes reading long discussions or past thread impossible. :-/
    I'm hoping to find a better news feed.

    Regards,
    Graeme



    GoogleGroups, not that I would suggest them as a 'good newsfeed', but
    Google did buy the DejaNews archive, and it probably is the best source
    if you want to look into historical Usenet.

    Seems to be problematical to use for posting, as it sounds like the
    interface is awful.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Graeme Geldenhuys@21:1/5 to Richard Damon on Sat Oct 10 14:57:29 2020
    On 10/10/2020 1:18 am, Richard Damon wrote:
    GoogleGroups, not that I would suggest them as a 'good newsfeed',

    Thanks Richard. I totally forgot about Google Groups. I used to use
    it years back. At least now I'll be able to search some older
    topics.

    Regards,
    Graeme

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)