Abstract
- Controlled by Device Controller
- Examples are like keyboard and monitor
Same IO Device but Different Performance Between CPP and Java
System.out.println()
in Java is much slower thancout
in CPP.
cout
typically performs buffered output by default, meaning it accumulates a certain amount of data before actually writing it to the output device. This reduces the number of System Call (系统调用) made, which can improve performance, especially when outputting a large amount of data.
System.out.print
in Java is synchronized for Thread Safety (线程安全), which can introduce some overheadHowever, buffer takes Main Memory, we need to a fine balance between the system call we reduce with buffer and the the memory usage incurred by the buffer. 512 Byte is common buffer size
Useful Commands
read
- Built-in for retrieving data from standard input and assign the value to a bash variable
- The command below displays a prompt before the input. Only works for BASH, not for ZSH
Terminologies
Plug and Play
- Kernel automatically collect information about the IO Device
- Centrally assign interrupt level & IO Addresses
- Tell each IO device what its numbers are
IO Operation
- The process of CPU communicating with the outside world. This can include interactions with humans, other computers, or peripheral devices as shown above. CPU is only involved in initiating the operation and processing the results of the operation!!!