On Unix based systems, when an application tries to access some privileged resources, such as attempting to request extra CPU cycles, or access to a certain memory location, the request is deferred to the kernel.

This is done by setting a ‘trap bit’, a bit that denotes that their action might need additional permission. The kernel then receives control, and then decides whether to allow or deny that particular action based on the policies set up. After that, control is transferred back to the application.

On a single core 2GHz Linux Machine, it takes about 50-100 ns (nanoseconds) to perform the above transition. While it looks negligible, it adds up, since this action happens innumerable times during the day and is necessary for a properly running OS.

Also, since these instructions have to be loaded on the hardware cache, existing content on the cache will be overwritten, and application content will be transferred to memory instead. Accessing the hardware cache takes an order of 10^1 cycles, while accessing memory might take 10^2 cycles. So, frequent transitions will adversely affect the overall efficiency of the computer.

I learnt this on Udacity’s wonderful course on Operating Systems at

Please do check it out if you’re interested!

Comment and share

  • page 1 of 1

Pranav

Software Engineer in SF. I enjoy learning about new technologies, and love to organize after hours hand on sessions to teach others. I am also an avid bicyclist, and enjoy biking up to Marin on weekends.


Full Stack Engineer at Pariveda Solutions