Workers and supervisors

Herd of workers and supervisors :).In real world workers are doing the actual work and supervisors are monitoring the behaviour of workers

Well ,here it is about Erlang supervisors.In Erlang Workers are processes which perform the actual work whereas supervisors are processes which monitor the behaviour of workers.At the same time supervisor can restart the worker if something goes wrong.

Graphical representation of supervisor and worker.

Rectangular shape -supervisor
eclipse /circular shape -worker.
This is called supervision tree.
According to this supervision tree, there is one supervisor and under that supervisor there is one worker.
In Erlang there are different types of supervisors are defined according to their behavior.

They are




Leave a comment

Posted by on May 9, 2009 in technology


Tags: , , ,

Red & Green

I just look around.I found some interesting subjects around our home garden.
So here they come..

First it comes a rose. This is an early stage of the rose.So it has a color near to pink.

Few days later it ll look like this.

This is an Anthurium bud.This will take two or more days to come out .
This is a grown Anthurium … long lasting flower.Another colorful flower..We called it කුඩලු.(kudalu).

Don’t know the proper name of this flower.Ixora
Peppers ..

Aloe vera & ගොටුකොල.


Posted by on May 8, 2009 in Uncategorized


Tags: , , , , ,


Bulk loading data into Mnesia

Mnesia is a DBMS which comes with the erlang distribution.Which is appropriate for
telecommunication applications which are realtime and continues
Mnesia provides read,write operations which can be used to load and search data.

Here the problem is bulk loading of data into mnesia table
say 1 million records.[records which has about 12 attributes]
tables which are disc_copies and disc_only_copies

create tables,both disc_copies and disc_only_copies
In disc_copies table kept in RAM as well as on disc.Where as in disc_only_copies table kept on disc_only

mnesia_create_tables(NodeList) ->
case mnesia:start() of
ok ->
error_logger:error_report([“Mnesia start ok”]),

[{disc_only_copies, NodeList},{type, set},
{attributes, record_info(fields, person)}]),

[{disc_copies, NodeList},{type, set},
{attributes, record_info(fields, subscriber)}]);

{error, Reason} ->
error_logger:error_report([“Mnesia start error: “, Reason]),
{error, Reason}

For bulk writing we can use two functions. one is mnesia:dirty_write and other one is
mnesia transaction mechanism.
Dirty operations are performance wise better than transaction mechanism.Its because dirty operations are bypassing much of processing
In transaction mechanism action is either performed or aborted.

Use dirty method for loading data.

dirty_populate_disc_copy(Rec) ->

dirty_populate_disc_copy(N,NumProc) ->
From =N,
To= N-trunc(N/5),

NumProc > 0 ->
io:format(“From=~w To=~w Pocess=~w~n”,[From,To,NumProc]),
NumProc ==0 ->

Used 5 spawns to load data into mnesia tables.
specify integer value for Rec .It will load that number of records into mnesia table.
%% ——————————————————————-
%% Populate the subscriber table :disc_copies
%% ——————————————————————-

populate_subscriber(From,To,Option) ->
Stime =erlang:localtime(),
do_populate_subscriber(From, To,Option),
{_, RT} = statistics(runtime),
{_, WC} = statistics(wall_clock),
io:format(“Start=~p End=~p~n~n”, [Stime, Etime]),
io:format(“Run Time=~p Wall Clock Time=(~p) milliseconds~n”, [RT, WC]).

do_populate_subscriber(FId,TId,Option) when FId > TId ->
Name = “abcddddd”,
GroupId = random:uniform(100) – 1,
Subscr = #subscriber{subscriber_number = FId,
subscriber_name = Name,
group_id = GroupId,
variable_id = GroupId,
variable_name = “sports”,
marketing_value = “12.4454555”,
length_variable = false,
location = 9064949,
active_sessions = 450000,
changed_by = <>,
changed_time = <>,
suffix = “222222”
Option == dirty ->
Option == trans ->

do_populate_subscriber(_,_,_) ->
io:format(” totally ~p bytes~n”,
[mnesia:table_info(subscriber, memory) * 4]),

save_record_dirty(DB,Record) ->

Find the complete module here

Leave a comment

Posted by on January 15, 2009 in technology


Tags: , , , , ,

Final year project

We just finished the demonstration of our final year project.It was a character generating tool.
Which means superimposing characters and animation over the live video on the fly.
This is the project blog.


Tags: , ,

Ideas are not protected under Law

Yesterday we had our Professional practice lectures.The lecture was focused on legal issues in professional work.The lecturer was Mr Jayantha Fernando who is a Legal Advisor -ICT Agency of Sri Lanka.He pointed out that even if we have our own ideas it can be used by some other person.And it is not prevented by the law.


Posted by on February 20, 2008 in professional, technology


Tags: ,

Moments Of Life

Life has become more stressful than ever before.

Leave a comment

Posted by on February 20, 2008 in Life


Trojan in Action -VS2005

I’m working with VS 2005 for my university project.During last week I got an unexpected exception ,
It was a divide by zero exception.The funniest thing is I haven’t use any arithmetic operations in my code.Due to this error ,I was unable to load the GUI properly.

Stupid error messages

WINDOWS\system32\msvcrt.dll’, No symbols loaded.
\WINDOWS\system32\MSCTF.dll’, No symbols loaded.
\WINDOWS\system32\advapi32.dll’, No symbols loaded.
\WINDOWS\system32\rpcrt4.dll’, No symbols loaded.
\WINDOWS\system32\amvo0.dll’, Binary was not built with debug information.

First-chance exception at 0x10016d66 in te.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x10015bb9 in te.exe: 0xC0000094: Integer division by zero.
First-chance exception at 0x8caf1379 in te.exe: 0xC0000005: Access violation reading location 0x8caf1379.
First-chance exception at 0x10015d12 in te.exe: 0xC0000005: Access violation writing location 0x00000000.
‘te.exe’: Unloaded ‘H:\WINDOWS\system32\amvo0.dll’
‘te.exe’: Loaded ‘H:\WINDOWS\system32\amvo0.dll’, Binary was not built with debug information.
First-chance exception at 0x10016d66 in te.exe: 0xC0000005: Access violation writing location 0x00000000.
First-chance exception at 0x10015bb9 in te.exe: 0xC0000094: Integer division by zero.
The program ‘[4944] te.exe: Native’ has exited with code 0 (0x0).

amvo0.dll is the file that cause the exception.It is a Trojan program which links with the VS2005 libraries.
I formated my hard drive and reinstalled the VS2005 .But it didn’t solve my problem :(.
I found a online virus scanning program from
It detected the Trojan programs,Apart from the amvo0.dll there were some other executable files also reside in my hard drives.
So I had to do a full system scan of my hard drives in order to remove AMV0 Trojan series

Leave a comment

Posted by on January 27, 2008 in technology


Tags: , , ,