Answering your last question: the array is really in the “core” of the memory, but the stack is allocated, which means that it “leaves” when the mycall () function completes. Perhaps your function works, but it may not work in cases where the memory is quickly used.
To return multiple values, the generic template is designed so that the caller can pass pointers to user space and fill them with the kernel routine. For example, you can pass two pointers for two values or define one structure that contains the values you need and will be populated by the kernel program.
payne source share