5

I am wondering if there is any difference between the MIPS syscall and trap instructions. I can't find anything involving this, so I am not sure if there is a difference. Traps seem to just be a conditional syscall, but some clarifying can be helpful.

Alex
  • 125
  • 2
  • 7

2 Answers2

3

The SYSCALL and TRAP instructions both trigger exceptions, but the resulting exception is of a different type (SystemCall versus Trap), and the operating system will likely handle them differently.

  • 2
    What do operating systems usually use traps for? – Alex Dec 22 '12 at 17:25
  • 2
    Typically, they don't. On most systems I've used, traps will just crash the process which triggers them, the same as most other CPU exceptions. –  Dec 22 '12 at 17:35
  • Should I just make it a conditional system call then to save some code when you possibly may need a system call. – Alex Dec 22 '12 at 17:44
  • 1
    Yes. You almost always need to do a bunch of setup surrounding a system call anyway, so it's not as though being able to make a system call conditional would do you much good. –  Dec 22 '12 at 18:22
2

A Trap is an exception switches to kernel mode by invoking a kernel sub-routine (any system call). Usually trap creates any kind of control transfer to operating system. Where as SYSCALL is synchronous and planned user process to kernel mode.

Sunil Bojanapally
  • 12,528
  • 4
  • 33
  • 46