3 ms·
I think you are over counting abstractions. printf copies to a buffer and eventually calls write(2). On Windows there is an additional layer: CRT implements un
by asveikau 6y ago
I think you are over counting abstractions. printf copies to a buffer and eventually calls write(2).
On Windows there is an additional layer: CRT implements unix-style integer file descriptors (io.h) before calling WriteFile.
- kstenerud 6y agoIt's usually printf() -> fwrite() -> write() -> syscall. You need the fwrite (or something equivalent) in there for buffering and concurrency, otherwise multithreaded printfs would stomp on each other.
- saagarjha 6y agoUsually you go through vfprintf, which is the “most generic” function, and that will grab the file’s lock.