General Discussions

Stacks – Function Call VS Interrupt


Indian Bloggers

Concept:
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.

Function Call:
A function call acts in user mode. It basically uses stack to store the following when a function call is made.

stack-function-call

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.

Interrupt Call:
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

stack-interrupt

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.

Advertisements

2 thoughts on “Stacks – Function Call VS Interrupt

Let me Know What you Think!

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s