I am taking an operating systems course. I have just learned about traps.
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 (a system call) because those run with a higher priority than user code
I would like to see how traps are implemented, but every source I can find on traps discusses them in the abstract. Are traps implemented in Assembly or C? Can you give example code that implements a trap?
The part of the trap I am most interested in is how I would begin writing my own system calls. An ideal example would be a trap that executes when you want to read a file in Linux.