mutual exclusion in PHP

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

Post Reply
kays_f
Forum Newbie
Posts: 1
Joined: Fri May 14, 2010 10:13 am

mutual exclusion in PHP

Post by kays_f »

Hi all,

We have designed a web site as an assignment (please read the rest) and came to the final step. This step includes a concurrency control. Let me explain the situation with an example.

In the system the user "doctor" assigns tests for a "patient", then, when any "lab technician" logs in the system he can see the patient name and the test assigned. In this case two or more technicians may try to submit the test result at the same time. For that reason we have to detect which technician clicked the submit button first (Actually it is not submit button but we have to detect which technician clicked the link of "submit result page" first). So the other results of the technicians can be rejected. We tried adding a flag attribute in the database (MySQL) but it didn't work. Then we tried a text read/write operation as a flag holder but again we were not successful. We saw a general solution called Peterson's solution but we could not manage to put it in PHP code (we have to think also multi user case of Peterson solution).

Any kind of suggestion/help is appreciated.

Thanks.
User avatar
PHPHorizons
Forum Contributor
Posts: 175
Joined: Mon Sep 14, 2009 11:38 pm

Re: mutual exclusion in PHP

Post by PHPHorizons »

Are you using a database for this?
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Re: mutual exclusion in PHP

Post by Weirdan »

kays_f wrote: Any kind of suggestion/help is appreciated.
Sounds like you want optimistic locking. See http://pooteeweet.org/blog/1552 for example of optimistic locking in php/mysql
mikosiko
Forum Regular
Posts: 757
Joined: Wed Jan 13, 2010 7:22 pm

Re: mutual exclusion in PHP

Post by mikosiko »

+1 on Weirdan suggestion and also you can look for more information about locking mechanism and strategies here for Innodb:

http://dev.mysql.com/doc/refman/5.0/en/ ... s-set.html

and here:
http://dev.mysql.com/doc/refman/5.0/en/ ... modes.html
Post Reply