Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
dhruv857 committed Feb 28, 2015
1 parent 72cd9db commit adcdb77
Show file tree
Hide file tree
Showing 32 changed files with 14,592 additions and 0 deletions.
Binary file added Screen Shot 2014-11-24 at 4.58.40 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screen Shot 2014-11-24 at 4.59.32 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screen Shot 2014-11-24 at 5.11.09 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screen Shot 2014-12-09 at 2.39.53 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Screen Shot 2014-12-09 at 2.39.54 PM.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
88 changes: 88 additions & 0 deletions Terminal Saved Output.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
Last login: Mon Nov 24 02:17:53 on ttys000
Dhruvils-MacBook-Air:~ Dhruv$ erl s 1
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.1 (abort with ^G)
1> cd("Desktop").
/Users/Dhruv/Desktop
ok
2> cd("erlang").
/Users/Dhruv/Desktop/erlang
ok
3> c(plists).
{ok,plists}
4> c(multicore).
{ok,multicore}
5> multicore:test1().
sort: results equal? = true, speedup = 1.3470528021837413
ok
6> multicore:test2().
fibo: results equal? = true, speedup = 1.9805322581386124
ok
7> halt().
Dhruvils-MacBook-Air:~ Dhruv$ erl s 2
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.1 (abort with ^G)
1> cd("Desktop").
/Users/Dhruv/Desktop
ok
2> cd("erlang").
/Users/Dhruv/Desktop/erlang
ok
3> c(plists).
{ok,plists}
4> c(multicore).
{ok,multicore}
5> multicore:test1().
sort: results equal? = true, speedup = 1.426408991000705
ok
6> multicore:test2().
fibo: results equal? = true, speedup = 2.022065653938672
ok
7> halt().
Dhruvils-MacBook-Air:~ Dhruv$ erl s 4
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.1 (abort with ^G)
1> cd("Desktop").
/Users/Dhruv/Desktop
ok
2> cd("erlang").
/Users/Dhruv/Desktop/erlang
ok
3> c(plists).
{ok,plists}
4> c(multicore).
{ok,multicore}
5> multicore:test1().
sort: results equal? = true, speedup = 1.596660354622138
ok
6> multicore:test2().
fibo: results equal? = true, speedup = 2.0072139246235396
ok
7> halt().
Dhruvils-MacBook-Air:~ Dhruv$ elr s 16
-bash: elr: command not found
Dhruvils-MacBook-Air:~ Dhruv$ erl s 16
Erlang/OTP 17 [erts-6.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]

Eshell V6.1 (abort with ^G)
1> cd("Desktop").
/Users/Dhruv/Desktop
ok
2> cd("erlang").
/Users/Dhruv/Desktop/erlang
ok
3> c(plists).
{ok,plists}
4> c(multicore).
{ok,multicore}
5> multicore:test1().
sort: results equal? = true, speedup = 1.58788652365463
ok
6> multicore:test2().
fibo: results equal? = true, speedup = 1.9929602588312
ok
7> halt().
Dhruvils-MacBook-Air:~ Dhruv$
Binary file added ans 2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added ans2.docx
Binary file not shown.
76 changes: 76 additions & 0 deletions ass4.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
-module(stat).
-export([start/1, center/1, first/0, second/0,third/0,fourth/0]).

center(0) ->
first ! finished ,
second ! finished,
third!finished,
fourth!finished,
io:format("~p P0 finished~n", [self()]);

center(N) ->
first ! {center, self()},
second ! {center,self()},
third ! {center,self()},
fourth ! {center,self()},
receive
{first,F_PID} ->
io:format("~p P0 received ~p P1~n", [self(),F_PID]);
{second,S_PID} ->
io:format("~p P0 received ~p P2 ~n",[self(),S_PID]);
{third,T_PID} ->
io:format("~p P0 received ~p P3 ~n",[self(),T_PID]);
{fourth,FO_PID} ->
io:format("~p P0 received ~p P4 ~n",[self(),FO_PID])
end,
center(N - 1).

first() ->
receive
finished ->
io:format("~p P1 finished~n", [self()]);
{center, Center_PID} ->
io:format("~p (P1 received ~p P0~n ~p", [self(),Center_PID]),
Center_PID ! {first,self()},
first()
end.

second() ->
receive
finished ->
io:format("~p P2 finished~n", [self()]);
{center, Center_PID} ->
io:format("~p P2 received ~p P0~n", [self(),Center_PID]),
Center_PID ! {second,self()},
second()
end.

third() ->
receive
finished ->
io:format("~p P3 finished~n", [self()]);
{center, Center_PID} ->
io:format("~p P3 received ~p P0~n", [self(),Center_PID]),
Center_PID ! {third,self()},
third()
end.

fourth() ->
receive
finished ->
io:format("~p P4 finished~n", [self()]);
{center, Center_PID} ->
io:format("~p P4 received ~p P0~n", [self(),Center_PID]),
Center_PID ! {fourth,self()},
fourth()
end.


start(A) ->

register(first, spawn(ass4, first, [])),
register(second, spawn(ass4, second, [])),
register(third, spawn(ass4, third, [])),
register(fourth, spawn(ass4, fourth, [])),
CID = spawn(ass4, center, [A]),
io:format("~p P0(center) started~n", [CID]).
Loading

0 comments on commit adcdb77

Please sign in to comment.