-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from mistupv/newCaseStudy
New case study
- Loading branch information
Showing
9 changed files
with
119 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
-module(airline). | ||
-export([main/0, agent/3, meManager/0]). | ||
|
||
main() -> | ||
Main = self(), | ||
MePid = spawn(?MODULE, meManager, []), | ||
spawn(?MODULE, agent, [1, Main, MePid]), | ||
spawn(?MODULE, agent, [2, Main, MePid]), | ||
seats(3). | ||
|
||
seats(Num) -> | ||
receive | ||
{numOfSeats, Pid} -> | ||
Pid ! {seats, Num}, | ||
seats(Num); | ||
{sell, Pid} -> | ||
io:format("Seat ~p sold!~n",[Num]), | ||
Pid ! {booked, Num}, | ||
seats(Num - 1) | ||
end. | ||
|
||
agent(NAg, Pid, MePid) -> | ||
MePid ! {requestMe, self()}, | ||
receive | ||
grantMe -> Pid ! {numOfSeats, self()}, | ||
receive | ||
{seats, Num} when Num > 0 -> | ||
Pid ! {sell, self()}, | ||
MePid ! {releaseMe}, | ||
receive | ||
{booked, _} -> agent(NAg, Pid, MePid) | ||
end; | ||
_ -> | ||
MePid ! {releaseMe}, | ||
io:format("Agent~p done!~n", [NAg]) | ||
end | ||
end. | ||
|
||
meManager() -> | ||
receive | ||
{requestMe, Pid} -> Pid ! grantMe | ||
end, | ||
receive | ||
{releaseMe} -> meManager() | ||
end. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
Example combining airline and meViolation case study. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Example described in the chapter on debugging in the final book of | ||
COST Action 1405, which is to appear. | ||
A copy of the chapter is available in this directory. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{trace_spawn,nonode@nohost,1,true}. | ||
{trace_spawn,nonode@nohost,2,true}. | ||
{trace_spawn,nonode@nohost,3,true}. | ||
{trace_receive,3}. | ||
{trace_send,4}. | ||
{trace_receive,5}. | ||
{trace_send,7}. | ||
{trace_receive,9}. | ||
{trace_send,11}. | ||
{trace_receive,12}. | ||
{trace_send,14}. | ||
{trace_receive,16}. | ||
{trace_send,17}. | ||
{trace_receive,22}. | ||
{trace_send,23}. | ||
{trace_receive,19}. | ||
{trace_send,24}. | ||
{trace_receive,25}. | ||
{trace_send,27}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{trace_receive,0}. | ||
{trace_send,1}. | ||
{trace_receive,6}. | ||
{trace_receive,2}. | ||
{trace_send,8}. | ||
{trace_receive,13}. | ||
{trace_receive,10}. | ||
{trace_send,15}. | ||
{trace_receive,20}. | ||
{trace_receive,18}. | ||
{trace_send,21}. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{trace_send,0}. | ||
{trace_receive,1}. | ||
{trace_send,3}. | ||
{trace_receive,4}. | ||
{trace_send,5}. | ||
{trace_send,6}. | ||
{trace_receive,7}. | ||
{trace_send,10}. | ||
{trace_receive,15}. | ||
{trace_send,16}. | ||
{trace_receive,17}. | ||
{trace_send,19}. | ||
{trace_send,20}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{trace_send,2}. | ||
{trace_receive,8}. | ||
{trace_send,9}. | ||
{trace_receive,11}. | ||
{trace_send,12}. | ||
{trace_send,13}. | ||
{trace_receive,14}. | ||
{trace_send,18}. | ||
{trace_receive,21}. | ||
{trace_send,22}. | ||
{trace_receive,23}. | ||
{trace_send,25}. | ||
{trace_send,26}. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{call,{airline,main,[]}}. | ||
{comp,1281000}. | ||
{exec,10000000}. | ||
{node,nonode@nohost}. | ||
{pid,0}. | ||
{return,none}. | ||
{tracing,timeout}. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters