Blocking Behavior Defined
Which statement best describes synchronous I/O in a simple program that reads a file before updating the screen?
- The program waits for the file read to finish before updating the screen.
- The program updates the screen while the file is still being read automatically.
- Synchronous I/O always uses many threds behind the scenes.
- Synchronous I/O is guaranteed to be faster than asynchronous I/O in all cases.
- Synchronous I/O means the code is asyncronous but spelled differently.
Non-Blocking Concept
When a program sends a network request using asynchronous I/O and then continues handling user input, what is happening?
- The program can continue processing user input while the network request is in progress.
- The program must stop until the network request finishes because all I/O is blocking.
- The program creates a new window for each request by default.
- The program switches from I/O-bound to CPU-bound automatically.
- The program is using syncronous behavior.
Keeping a UI Responsive
In a single-threaded app that loads images from disk without freezing the buttons, which approach should you choose?
- Use asynchronous I/O for the image loads so the UI stays responsive.
- Use synchronous I/O everywhere and expect the UI to remain smooth.
- Use a busy-wait loop to check the disk repeatedly.
- Disable all user input until loading finishes to avoid bugs.
- Rely on disk caching and keep using blocking reads.
Simplicity vs Concurrency
For a short sequence like open file, read data, and close file, which approach is usually simplest to write and understand?
- Synchronous I/O with straightforward step-by-step code.
- Asynchronous I/O with multiple nested callbaks.
- Asyncronous I/O with random delays inserted.
- Using a custom scheduler and event loop for everything.
- A busy-wait that polls the disk constantly.
Completion Notification
When an asynchronous file read finishes, how do programs commonly find out that the data is ready?
- A callback, promise, or future is triggered to deliver the result.
- A syntax error appears in the source code automatically.
- The result replaces the source file name by magic.
- Only by repeatedly polling with a tight loop is it possible.
- The process is terminated and restarted with the data.
What Blocking Means for a Thread
In blocking (synchronous) I/O, what does the active thread do while waiting for data from the network?
- It pauses and cannot perform other tasks until the operation completes.
- It continues running other unrelated tasks automatically.
- It hands the work to the GPU to finish instantly.
- It silently converts the operation into asyncronous mode.
- It saves and loads the entire program state every millisecond.
Scalability With Many Connections
When a server must handle thousands of mostly idle connections, which I/O model typically scales better with fewer threads?
- Asynchronous I/O with event-driven handling.
- Synchronous I/O with one thread per connection.
- Synchronous I/O using busy waiting on every socket.
- A single blocking thread that loops through connections in order.
- Asyncronous I/O that blocks on every read call.
I/O-Bound vs CPU-Bound
What is a true statement about using asynchronous I/O for a CPU-bound task such as large number crunching?
- Asynchronous I/O does not speed up CPU-bound work; it mainly helps overlap waiting for I/O.
- Asynchronous I/O automatically parallelizes CPU calculations.
- Asynchronous I/O reduces the number of CPU instructions required.
- Asynchronous I/O guarantees lower power usage for all tasks.
- Asynchronous I/O increases numeric precision during math operations.
Completion Order
If you start two asynchronous network requests A and then B, what completion order can occur in practice?
- B can finish before A depending on timing and network conditions.
- They must finish at exactly the same time by design.
- They always finish in the order started because async is ordered.
- A never finishes if B is started after it.
- The operating system renames them to enforce order.
Error Handling Differences
Compared to synchronous I/O that might throw an error immediately at the call site, how are errors typically delivered in asynchronous I/O?
- Errors are delivered later through a completion mechanism such as a callback or a rejected future.
- Errors are never reported in asynchronous I/O.
- Errors only appear as typos in variable names.
- Errors are converted into successful results automatically.
- Errors always crash the computer instantly.