Exercises

team bbl


14.1

Write a test program that illustrates your system's behavior when a process is blocked trying to write-lock a range of a file and additional read-lock requests are made. Is the process requesting a write lock starved by the processes read-locking the file?

14.2

Take a look at your system's headers and examine the implementation of select and the four FD_ macros.

14.3

The system headers usually have a built-in limit on the maximum number of descriptors that the fd_set data type can handle. Assume that we need to increase this limit to handle up to 2,048 descriptors. How can we do this?

14.4

Compare the functions provided for signal sets (Section 10.11) and the fd_set descriptor sets. Also compare the implementation of the two on your system.

14.5

How many types of information does getmsg return?

14.6

Implement the function sleep_us, which is similar to sleep, but waits for a specified number of microseconds. Use either select or poll. Compare this function to the BSD usleep function.

14.7

Can you implement the functions TELL_WAIT, TELL_PARENT, TELL_CHILD, WAIT_PARENT, and WAIT_CHILD from Figure 10.24 using advisory record locking instead of signals? If so, code and test your implementation.

14.8

Determine the capacity of a pipe using nonblocking writes. Compare this value with the value of PIPE_BUF from Chapter 2.

14.9

Recall Figure 14.28. Determine the break-even point on your system where using writev is faster than copying the data yourself and using a single write.

14.10

Run the program in Figure 14.32 to copy a file and determine whether the last-access time for the input file is updated.

14.11

In the program from Figure 14.32, close the input file after calling mmap to verify that closing the descriptor does not invalidate the memory-mapped I/O.

    team bbl



    Advanced Programming in the UNIX Environment
    Advanced Programming in the UNIX Environment, Second Edition (Addison-Wesley Professional Computing Series)
    ISBN: 0321525949
    EAN: 2147483647
    Year: 2005
    Pages: 370

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net