Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

What are advantages and disadvantages of recursive
calling ?

Answer Posted / sk_seeker

Why is recursion frowned upon??

User space programs: memory consumption
----------------------------------------
User stack is a dynamic stack i.e. we page fault on the
stack virtual addresses and resolve the fault by allocating
a physical page. Many recursions can lead to a lot of (user
stack) memory being consumed. In a traditional programming
model, when a thread blocks, then all the memory is stuck
with the thread, until the paging daemon kicks it out. So,
effectively, many threads doing recursive calls can consume
a lot of memory and force memory pressure to occur in the
system i.e. system slows down.

Kernel Space program: stack depth
---------------------------------
A kernel stack is fixed in size i.e. 8K or 16K usually. And
this stack does not grow dynamically in most OSes. So,
there is a bound on how much memory can be used for the
kernel stack, unlike user programs. But, this bound on the
stack size is the reason why recursion is discouraged. More
recursive levels can lead to a stack overflow and this will
panic the box. One might say: hey, my recursive depth is
only 10. But, what is unknown is what amount of kernel
stack is already used up && the stack frame consumption
depends on the chip architecture that is being used.

For both of the above reasons, recursion is avoided in
general kernel programming.

Is This Answer Correct ?    20 Yes 12 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why c is faster than c++?

1046


Does c have function or method?

1009


GIven a sequence of characters. How will you convert the lower case characters to upper case characters. ( Try using bit vector - sol given in the C lib -> typec.h)

1112


Explain what is a const pointer?

1091


#include main() { int *p, *c, i; i = 5; p = (int*) (malloc(sizeof(i))); printf(" %d",*p); *p = 10; printf(" %d %d",i,*p); c = (int*) calloc(2); printf(" %d ",*c); }

1060


How important is structure in life?

1091


What are global variables?

1198


Can you write the function prototype, definition and mention the other requirements.

1146


What is string constants?

1155


how to execute a program using if else condition and the output should enter number and the number is odd only...

2311


If I have a char * variable pointing to the name of a function ..

1176


What does %d do in c?

968


FORMATTED INPUT/OUTPUT functions are a) scanf() and printf() b) gets() and puts() c) getchar() and putchar() d) all the above

1122


Explain the advantages and disadvantages of macros.

1105


When do you not use the keyword 'return' when defining a function a) Always b) Never c) When the function returns void d) dfd

1065