module STOCKS (DATAP, CHANNELS) is !update "2021-b" -- use standard operator priority ------------------------------------------------------------------------------- process Stock_a [Deposit: DepositChan, Withdraw: WithdrawChan] (M_a: Amount, prd: Product, in var amt: Amount) is var newamt: Amount in loop alt Deposit (prd, ?newamt) where newamt <= M_a and newamt > 0 of Amount; amt := amt + newamt [] Withdraw (prd, ?newamt) where newamt <= M_a and newamt <= amt; amt := amt - newamt end alt end loop end var end process ------------------------------------------------------------------------------- process Stock_p0 [Deposit: DepositChan, Withdraw: WithdrawChan] (M_a:Amount) is Stock_a [Deposit, Withdraw] (M_a, 0 of Product, 0 of Amount) end process ------------------------------------------------------------------------------- process Stock_p1 [Deposit: DepositChan, Withdraw: WithdrawChan] (M_a:Amount) is Stock_a [Deposit, Withdraw] (M_a, 1 of Product, 0 of Amount) end process ------------------------------------------------------------------------------- end module