I understand this:User code executes in a process/thread context in a process address space, in user mode, and  can address only user code/data defined for the process, with no access to privileged instructions. How does operating system know the process/thread created by user is in the user space, and in user mode, instead of kernel space and kernel mode? Is it controlled by register/cpu/hardware settings? How exactly does it work?   
How is user space process/thread controlled by the operating system
linux;process;linux kernel