The Linux Programming Interface

(nextflipdebug5) #1

1434 Appendix F


Chapter 47


47-5. A solution is provided in the file svsem/event_flags.c in the source code distribution
for this book.
47-6. A reserve operation can be implemented by reading a byte from the FIFO.
Conversely, a release operation can be implemented by writing a byte to the
FIFO. A conditional reserve operation can be implemented as a nonblocking read of
a byte from the FIFO.

Chapter 48


48-2. Since access to the shmp–> cnt value in the for loop increment step is no longer
protected by the semaphore, there is a race condition between the writer next
updating this value and the reader fetching it.
48-4. A solution is provided in the file svshm/svshm_mon.c in the source code distribution
for this book.

Chapter 49


49-1. A solution is provided in the file mmap/mmcopy.c in the source code distribution for
this book.

Chapter 50


50-2. A solution is provided in the file vmem/madvise_dontneed.c in the source code
distribution for this book.

Chapter 52


52-6. A solution is provided in the file pmsg/mq_notify_sigwaitinfo.c in the source code
distribution for this book.
52-7. It would not be safe to make buffer global. Once message notification is reenabled
in threadFunc(), there is a chance that a second notification would be generated
while threadFunc() is still executing. This second notification could initiate a second
thread that executes threadFunc() at the same time as the first thread. Both threads
would attempt to use the same global buffer, with unpredictable results. Note that
the behavior here is implementation-dependent. SUSv3 permits an implementa-
tion to sequentially deliver notifications to the same thread. However, it is also per-
missible to deliver notifications in separate threads that execute concurrently, and
this is what Linux does.

Chapter 53


53-2. A solution is provided in the file psem/psem_timedwait.c in the source code distribu-
tion for this book.
Free download pdf