Which of the following methods are used to pass any number of parameters to…
2019
Which of the following methods are used to pass any number of parameters to the operating system through system calls?
- A.
Registers
- B.
Block or table in main memory
- C.
Stack
- D.
Block in main memory and stack
Attempted by 896 students.
Show answer & explanation
Correct answer: D
Answer: Block in main memory and stack
Why this is correct:
Stack — the caller pushes parameters onto the user stack before the system call; the kernel retrieves them from the stack using the stack pointer. This approach supports a variable number of parameters.
Block in main memory — the caller constructs a contiguous block or table (for example, an array) containing all parameters and passes a pointer to that block; the kernel dereferences the pointer and reads the parameters. This method is suitable for arbitrarily many or large parameters.
Why not registers alone:
Registers are limited in number and can carry only a small, fixed number of arguments. For this reason, registers alone cannot handle arbitrary-length parameter lists.
Typical implementation:
A hybrid approach is common: small or frequently used arguments are placed in registers for speed, and remaining arguments are passed on the stack or via a pointer to a memory block.
A video solution is available for this question — log in and enroll to watch it.