Date: Fri, 27 Sep 1996 14:17:04 -0500 From: Max Hailperin To: f-math-computer-science-78@gac.edu Subject: shutdown with pending puts I mentioned in lab today that until one lab group raised it, I hadn't considered the question of what should happen if a bounded buffer is shutdown while one or more puts are waiting for space. I said that the "right" solution was to wait for the puts to complete before actually doing the shutdown, but that it was OK with me if you just ignored this issue. Since then I've thought about this a bit more, and there are at least four options (other than ignoring the issue) that are arguably "right": (1) As suggested above, wait for the puts to complete before doing the actual shutdown. Moreover, the call to the shutdown procedure shouldn't return until after the actual shutdown has occured (so it blocks until the pending puts are complete). (2) As above, wait for the puts to complete before doing the actual shutdown. However, have the shutdown procedure return immediately anyway, even though the buffer won't really be shutdown until the last pending put is done. (3) Signal an error from the shutdown procedure if any puts are pending, analogous to the error in put if the buffer is already shut. (4) Instead, have shutdown wake up the pending puts and have them then signal the error (exactly as though the shutdown had been done before they were called). If error signalling terminates the whole program (as currently) this is no different than 3, but in other circumstances it might matter whether the error was signaled from shutdown or from put. I said that implementing the "right" solution would require a change in the data structure (i.e., in the boundedbuf.h file). As it turns out, one of the above, namely option 4, doesn't require such a change. It does, however, require a change to the code of the put procedure I gave you. All the others also require changes to the code of put, and -- as far as I can see -- also changes to the data structure. As I said before, I will accept a solution of just ignoring this issue -- so it would be a good thing to postpone. However, I will also accept any of the four options above, rather than just a single "right" approach. I would encourage you to think about the relative merits of the four approaches, even if you don't implement any of them. -max