有限状态过程 - 建模并发问题?

时间:2016-04-02 07:04:05

标签: concurrency state-machine concurrent-programming

我已经分配了一项任务,为以下场景提供LTSA建模。

Customers need to buy tickets to watch a show in a theater. The tickets are only issued at the counter on the day
of the show. Ticket holders are then showed to their respective seats by an Usher. 
There are two ticket Counters. Tickets can be issued by any Counter
There is only one main door.
There are only 3 Ushers available to seat the clients.
Customers can arrive in any order.
The management need to ensure that each customer is treated fairly to avoid a possible gate-crash.

这是迄今为止我能够开发的LTSA代码。

const T_M = 3 
const C_M = 2


range T_R = 1..T_M //Range of tickets available
range C_R= 1..C_M //Range of counters


HOLDCOUNTER = ( holdCounter[c:C_R]-> release[c] -> HOLDCOUNTER).
CUSTOMER = ( gotoCounter[c:C_R] -> holdCounter[c] -> buyTicket[c] -> releaseCounter[c] -> STOP).
COUNTER = ( holdCounter[c:C_R]-> buyTicket[c] -> issueTicket[c] -> COUNTER).

||CUSTOMERS = ([c:T_R]:CUSTOMER).

||THEATER = ( CUSTOMERS || [counter:C_R]:COUNTER || HOLDCOUNTER).

但是当我运行它时,似乎当CUSTOMER 1进入​​COUNTER 1时,COUNTER 1可供CUSTOMER 2使用,这是错误的。结果应该是当CUSTOMER使用COUNTER时,该COUNTER应该与其他CUSTOMERS锁定,直到客户完成它。

我认为重新标记动作' holdCounter' CUSTOMERS的复合过程可以提供帮助,但我不知道如何正确地做到这一点。

有人可以帮忙吗?提前谢谢。

0 个答案:

没有答案