MOO-cows Mailing List Archive

[Prev][Next][Index][Thread]

Re: Mutual Exclusion



>Basically, all you need to ensure is that you do not suspend between
>reading the variable, and writing to the variable, and all is well :^)
>
>Regards,
>
>Ian.

I don't think you're right here. I suppose there is some kind of scheduler in
the moo-server, and it just can occur that the two verbs are being
executed at the same time. So maybe at program level everything is ok, but at
server level they might be scheduled wrong, so the problem won't disappear.
The only way of making sure everything is ok is by implementing some kind of
``semaphore'' or ``monitor'' in your moo-code (I think).

robot 1 : 
  1 read(CB,x)
  2 dec(x,100)
  3 write(CB,x)

robot 2:
  4 read(CB,x)
  5 dec(x,200)
  6 write(CB,x)

Might be scheduled like 1 4 2 3 5 6, and the final CB is 100 too high...

Yours,
  
  Pieter-Bas

-- 
                      P.B. IJdens (pbijdens@cs.ruu.nl)
      Department of Computer Science, Utrecht University (the Netherlands)
       WWW: http://huizen.dds.nl/~pbijdens/  (also for my PGP public key)
********************** quod scripsi scripsi (Joh: 19:22) **********************


Follow-Ups: References:

Home | Subject Index | Thread Index