In the fragile queue library, can only the functions in that library change queue data?
- No, but the user can only change values in the queue; the library functions must be called to change values in the queue structures
- No, but the user can only change values in the queue structure; the library functions must be called to change values in the queue
- Yes, you have to call one of those functions to change the values in the queue or queue structure
- No, the user can change not only the values in the queue but also in the queue structure
As the queue structure in the robust library is a "dangerous implement", how does the caller refer to a queue?
- The queue creation functions return an index that refers to the queue, and that index is passed to library functions for queue operations.
- The queue creation functions return a token encoding information about the queue, and that token is passed to library functions for queue operations.
- The queue creation functions return the address of the queue, which is then passed to library functions for queue operations.
- The queue creation functions create a printable 4-character name for the queue, and that name is passed to library functions for queue operations.
In the robust library, what is the nonce used for?
- To distinguish a current queue from a deleted one with the same index
- To enable a forged token to be detected
- To count the number of queues created
- To create a unique index for each queue
In the robust library, the token generation function qtktref always returns a token with the high order bit (sign bit) 0. Why?
- A negative token means the function is called with a negative index
- If the sign bit is 1, then the token cannot be 0
- A negative token might be confused with an error indicator
- A negative token will be ignored by the caller
In the robust library's take_off_queue function, after an if/else statement in which the else is unconditional (that is, not an else if), there is code to report an inconsistency that should never be reached. Which of the following is the best explanation for why is it there?
- Someone might change the if/else in such a way that neither branch is taken, creating a way to reach that part of the code
- It is there to ensure that anyone who reads the code will know the author of the code programmed it robustly.
- The compiler might compile the code incorrectly, and leave a way to reach that part of the code
- The computer may execute something incorrectly and cause a branch to that part of the code
Which of the following is *not* a problem with the put_on_queue() routine in the fragile library?
- Its arguments are not checked for validity.
- Queue overflow may occur.
- The count field in the queue structure may not reflect the actual number of elements in the queue.
- Queue underflow may occur.
Which of the following is not a problem with the qmanage() routine in the fragile library?
- The values of flag (the second parameter) and size (the third parameter) may be easily confused.
- The value of size may be negative.
- The address returned by the memory allocation routine is not checked, as virtual memory makes running out of memory very unlikely.
- The size of the queue may vary among systems