since I/O instructions are privileged instructions that require mode switch from user to kernel, is printf also considered a privileged instruction? is there mode switch when performing printf instructions?
is printf also considered a privileged instruction?
No, the printf
is not privileged, nor an instruction, it is a function call.
is there mode switch when performing printf [function calls]?
Yes, eventually inside printf it will do a write function call and that will pass over to kernel mode. Note however, because of buffering, the pass to kernel mode may not happen on the first printf
call, and may be delayed until buffers are full or fflush
is called.