tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: How to destroy a condvar(9) with waiters?



   Date: Tue, 29 Dec 2015 10:41:39 +0100
   From: Stephan <stephanwib%googlemail.com@localhost>

   I think I found another approach. The destruction is now split in two parts:

   1) The destroyer changes the state to destroyed and removes the object
   from the global list.
   2) Each waiter checks the state and waiters count of the object. If
   the state is "destroyed" and the waiters count equals zero, a
   "delete_physical()" function is called which destroys the CVs,
   releases and destroys the interlock and finally frees all memory.

This works too, but sometimes

(a) it's not convenient for the waiters to have to handle destruction
(e.g., they're holding other resources and don't want to do kmem_free
and thus touch uvm), and

(b) it's useful for one party, the destroyer, to know when all waiters
are complete.

It depends on your application's needs.  Both approaches will work.


Home | Main Index | Thread Index | Old Index