8.) What is the difference between select() & poll()?
-
a) select() and poll() have no differences
-
b) poll() is event driven while select() is not
-
c) select() is event driven while poll() is not
-
d) None
While both monitor multiple file descriptors, poll() is event-driven and scales better because it uses a structure array instead of bitmasks, whereas select() requires rebuilding the descriptor sets every time.
To answer this question, let's go through each option to understand why it is correct or incorrect:
Option A) select() and poll() have no differences - This option is incorrect because select() and poll() do have differences.
Option B) poll() is event-driven while select() is not - This option is correct. The main difference between select() and poll() lies in their behavior. poll() is event-driven, meaning that it only checks for events when explicitly called. It does not block the execution of the program. On the other hand, select() is not event-driven and blocks the program's execution until an event occurs.
Option C) select() is event-driven while poll() is not - This option is incorrect. The correct statement is the opposite: poll() is event-driven while select() is not.
Option D) None - This option is incorrect because there are differences between select() and poll().
The correct answer is B) poll() is event-driven while select() is not.