trapping into the kernel (the mode switch)
Go back to the hotel front desk. You cannot just wander behind the desk into the back office - there is a counter in the way. Instead you ring a bell that the staff have agreed to answer; when it rings, a specific employee comes to a specific spot, with a specific procedure, and only then handles your request. Trapping into the kernel is exactly that bell: a single, deliberate signal that hands control to the kernel at a place the kernel chose in advance.
Here is the mechanism, step by step. The program puts a system-call number into a register (saying which service it wants) and the arguments into other registers. It then executes one special instruction - on modern x86-64 this is the syscall instruction; historically programs used a software interrupt like int 0x80. That instruction does several things at once: it switches the CPU from user mode to kernel mode, it saves where the program was so it can come back, and it jumps to a fixed kernel entry point that was registered when the machine booted. The program cannot pick where it lands; it always lands in the kernel's trusted handler. The kernel then reads the number, dispatches to the right routine, does the work, puts a return value in a register, and executes a return-from-kernel instruction that switches back to user mode and resumes the program right after the trap. This whole controlled transfer is called a trap.
Why it matters: this fixed, one-way doorway is what keeps the privilege wall safe. A program cannot jump to an arbitrary address inside the kernel - it can only ring the bell and land where the kernel is ready for it. That is also why a system call is more expensive than a plain function call: it involves saving state and switching modes, not just a jump. The word 'trap' here means a deliberate, synchronous switch caused by an instruction the program ran on purpose - distinct from an interrupt, which arrives from outside, and a fault, which signals an error.
On Linux x86-64, a write() boils down to: put the syscall number for write into the rax register, the file descriptor in rdi, the buffer address in rsi, the length in rdx, then execute the syscall instruction. The CPU traps into the kernel, which performs the write and returns the byte count in rax.
Number and arguments go in registers; one instruction does the mode switch.
A trap is synchronous and intentional - the program asked for it by running an instruction. Do not confuse it with a hardware interrupt (asynchronous, from a device) or a fault (the CPU signaling that an instruction went wrong). All three transfer control to the kernel, but for different reasons.