computer science questions

"Do you want an original answer to this question?

Yes No

[1] Why does a different version of stat(), lstat(), exist that treats symbolic links differently? Why isn’t a different version needed for hard links?

[1] How can you modify 3000pc so the producer stops producing once it fills the queue?

[1] Under what circumstances is fill_rand_buffer() called in 3000random?

[1] If the two signal handling functions in 3000pc were replaced by one function, would there be any significant loss of functionality? Briefly explain.

[2] How could you modify 3000test.c so it can report on whether two device files are equal without actually accessing the underlying devices? Specify the changes you would make to 3000test.c rather than doing this from scratch.

[2] Does the MAP_SHARED flag on line 60 of 3000test.c (inside the call to mmap) make a significant difference in its execution? Specifically, what happens when you remove it or changed it to MAP_PRIVATE? Why?

[2] When a file is mmap’d into memory, when is its contents loaded from disk? How can you verify this using 3000test?

[2] What is one way simple way you can modify 3000pc so the consumer consumes as the producer produces, i.e., the producer and the consumer move essentially in lock step? Your modification should not involve sleeping by either the producer or the consumer. Why does your change work? (To do this precisely is hard; to do this approximately involves a change to one line. The approximate solution is sufficient.)

[2] Which is faster, /dev/urandom or /dev/random? What evidence do you have for this difference based on code that you ran (3000random or other programs)?

[2] How does the behavior of 3000pc change if you delete lines 149 and 152 (the if statement in wakeup_consumer())? Why? (Explain what the program does after this change and why it may be problematic.)

[2] What happens if you delete line 231 (the call to wakeup_producer()) in 3000pc? Why?

[2] How does the behavior of the program change if you change QUEUESIZE to 8? What about 128?