-
Notifications
You must be signed in to change notification settings - Fork 2
Description
Should the common BIOS API have naive blocking functions? They are easy to use and simple to implement, but they hurt performance (e.g. printing 15 characters when you only have an 8 character FIFO will cause the CPU to spin for the duration of 7 characters - or 608 microseconds at 115,200 bps).
Non-blocking functions are more complicated - you'd have to get some aynchronous object back which represents the transaction which you'd need to poll for completion at some later date (c.f. Windows Overlapped IO).
A compromise might be functions which process as much data as they can without spinning, and return a value indicating how much has been processed. Obviously disk reads block until the entire sector is available, but writing a [u8; 16] to a UART might write half the buffer into a FIFO and then return 8 to indicate some data was left unwritten. The OS can then decide whether to retry immediately or come back later after doing some other work.