Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #39588
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2020-07-28 00:23 -0700 |
| References | <1164416886.789925.124600@14g2000cws.googlegroups.com> |
| Message-ID | <33d9c429-bf65-4dca-aaaa-cd65ffdbbc95o@googlegroups.com> (permalink) |
| Subject | Re: Peterson's Algorithm in java, sequencial instruction execution ? |
| From | dipanseshagiri@gmail.com |
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
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Peterson's Algorithm in java, sequencial instruction execution ? dipanseshagiri@gmail.com - 2020-07-28 00:23 -0700
Re: Peterson's Algorithm in java, sequencial instruction execution ? Graeme Geldenhuys <graemeg@example.net> - 2020-10-09 23:51 +0100
Re: Peterson's Algorithm in java, sequencial instruction execution ? Richard Damon <Richard@Damon-Family.org> - 2020-10-09 20:18 -0400
Re: Peterson's Algorithm in java, sequencial instruction execution ? Graeme Geldenhuys <graemeg@example.net> - 2020-10-10 14:57 +0100
csiph-web