Skip to content

Commit

Permalink
Merge pull request #24 from mistupv/newCaseStudy
Browse files Browse the repository at this point in the history
New case study
  • Loading branch information
lanese authored Oct 5, 2024
2 parents 473632b + 4bdf3bb commit b15f4c6
Show file tree
Hide file tree
Showing 9 changed files with 119 additions and 44 deletions.
45 changes: 45 additions & 0 deletions case-studies/airlineMe/airline.erl
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.
3 changes: 3 additions & 0 deletions case-studies/airlineMe/info.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Example combining airline and meViolation case study.


5 changes: 5 additions & 0 deletions case-studies/airlineMe/info.txt~
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.


19 changes: 19 additions & 0 deletions case-studies/airlineMe/trace/trace_0.log
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}.
13 changes: 13 additions & 0 deletions case-studies/airlineMe/trace/trace_1.log
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}.


13 changes: 13 additions & 0 deletions case-studies/airlineMe/trace/trace_2.log
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}.
13 changes: 13 additions & 0 deletions case-studies/airlineMe/trace/trace_3.log
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}.
8 changes: 8 additions & 0 deletions case-studies/airlineMe/trace/trace_result.log
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}.

44 changes: 0 additions & 44 deletions case-studies/info.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,47 +7,3 @@ Traces are in a dedicated directory including a file trace_result.log
with general information and a number of files trace_NNN.log
containing the trace of file NNN.

The file trace_result.log contains the following information:

1) executed call

call "module:function()" e.g. call "purchase:main()"

2) pid assigned to main process

main_pid NNN e.g. main_pid 63

3) result of the main process

result VALUE e.g. result false

Each file trace_NNN.log is a sequence of tuples with the following forms:

1) spawn instructions

{PID1,spawn,PID2} e.g. {63,spawn,70}

Process with pid PID1 spawned process with pid PID2

2) send instructions

{PID,send,MSGID} e.g. {70,send,2}

Process with pid PID sent message with unique message identifier MSGID.

NOTE: unique message identifiers do not exist in Erlang and are added
by our instrumentation. They allow one to link a send with the
corresponding receive and allow one to have more precise causal
information.

3) receive instructions

{PID,'receive',MSGID} e.g. {63,'receive',3}

Process with pid PID received message with unique message identifier
MSGID.

NOTE: unique message identifiers do not exist in Erlang and are added
by our instrumentation. They allow one to link a send with the
corresponding receive and allow one to have more precise causal
information.

0 comments on commit b15f4c6

Please sign in to comment.