Function calls are typically implemented by an instruction or an instruction sequence (the calling sequence) that pushes certain information on the stack. Calls to interrupt handlers typically begin with the hardware’s interrupt transfer mechanism followed by some instructions to push certain information on the stack.
This post presents the difference between the information pushed on the stack by a typical function call and by response to a typical interrupt.
A function call acts in user mode. It basically uses stack to store the following when a function call is made.
Also, it can be used for short-term large-scale storage of data when using recursive functions that store partial data in the stack and call themselves again.
An interrupt acts in kernel mode. It generally saves current program counter, program status word and flag registers. It then jumps to service the interrupt.
Following all are saved with respect to kernel, process and file whenever an interrupt occurs
Differentiating Between Both Calls:
A function pushes stack with,
- Return address
- Contents of the few general purpose registers
Where as an interrupt service routine,
- General purpose registers
- Parts of the processor state like
- Program status word, Process state, Process name
- Program counter, Stack pointer
- Current scheduling priority
- Message queue pointers
- Pending signal bits, Various flag bits
- Pointer to text, bss , data segments
- Exit status, Signal status
- Process ID, Parent process, Process group
- UMASK mask
- Root and working directory
- Real ID, Effective UID, Real GID, Effective GID etc.
which include memory, kernel, process and file management fields.