@shady : It allows us to allocate m/m dynamically ..which in itself is
very big advantage.
m/m consumption can be ignored , if you compare with the flexibility
it provides.
eg:-

int *arr=(int *)malloc(sizeof(int) * 100);

now  m/m consumption here is 100*4+8;// extra 8 wont hurt if you
compare with the advantage.

another advantage:-
suppose dere are 1000 integer value stored in
m/m...a1,a2,a3,a4....a100...now among all these only one is active at
a particular time T.
now to make it more interesting,suppose multiple threads want to find
which one is active at a particular time T.

it would be better if we have int *active pointer.
now anyone among a1,a2,a3....a100 becomes active then we store its
address to *active.All threads now just need to synchronize and check
*active pointer to find which one is active at a particular time T
among a1,a2,a3...a10.... instead of checking each variable which is
time consuming and may corrupt at some time.
I hope it helps.


now suppose mutiple threads are accessing sam

-- 


Reply via email to