-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
14,592 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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$ |
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,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]). |
Oops, something went wrong.