User:Lalit.sachdeva/sandbox

Trap
A Trap is an exception in a user process. It's caused by division by zero or invalid memory access. It's also the usual way to invoke a kernel routine(i.e. a System Call) because those run with a higher priority than user code. Handling is synchronous(so the user code is suspended and continues afterwards). E.g. Let say there are multiple processes running by the CPU few of them are user initiated and other are system call's. So CPU place system call above all the user processes i.e. All the system calls have the higher priority then User initiated process. And a user process is running, now a high priority system call arrive;than to stop the user process to execute the system call. The user process is stopped till the high priority system call completes it's execution and the user process is trapped and the process is known as trap.