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
In cryptography, you could often break the algorithm if you know what was the original (plain) text that was encoded into the current ciphertext. This is called the plain text attack. In this simple problem, we illustrate the plain text attack on a simple substitution cipher encryption, where you know each letter has been substituted with a different letter from the alphabet but you don’t know what that letter is. You are given the cipherText as the input string to the function getwordSets(). You know that a plain text "AMMUNITION" occurs somewhere in this cipher text. Now, you have to find out which sets of characters corresponds to the encrypted form of the "AMMUNITION". You can assume that the encryption follows simple substitution only. [Hint: You could use the pattern in the "AMMUNITION" like MM occurring twice together to identify this]
Calculate 1*2*3*____*n using recursive function??
how to solve "unable to open stdio.h and conio.h header files in windows 7 by using Dos-box software
What is page thrashing?
How can I check whether a file exists? I want to warn the user if a requested input file is missing.
How can I write functions that take a variable number of arguments?
The statement, int(*x[]) () what does in indicate?
What is const volatile variable in c?
What is the difference between a function and a method in c?
Why we not create function inside function.
I need a sort of an approximate strcmp routine?
Why isn't it being handled properly?
What is a nested loop?
Define and explain about ! Operator?
Write a C program on Centralized OLTP, Decentralized OLTP using locking mechanism, Semaphore using locking mechanism, Shared memory, message queues, channel of communication, sockets and a simple program on Saving bank application program using OLTP in IPC?