A common x86 CPU has two different modes (here can we subdivide again into protection rings). One is the user mode and the other is the kernel mode.
The kernel mode has full access to the hardware. Basically you should be careful to execute something here.
For security reasons you choose the user mode for normal applications like a web server.
To call a kernel function, for example, an expensive context switch must take place.
Now to my question: Apart from the fact that it would be irresponsible to run a normal application in kernel mode, it would be possible in theory to run an application like a simple HTTP server in kernel mode.
However, the system would have to be perfect for this: The HTTP server is bug-free. This is basically not possible in practice. Also, the CPU could have a security hole, which makes this much more tragic.
Now we assume that the system would really be 100% perfect and we would run an application in kernel mode. Is this performance difference noticeable?
Has anyone tried this out and published benchmarks?