concurrent access and free of heap object
问题 This question is a possible sub problem to this concurrent access and free of a data structure The other question is open to design, this one is more concrete. struct ds { int x,y,z; pthread_mutex_t mutex; }; I need a deterministic solution via which I can concurrently access 1 object of type ds and free it. Constrains: You can make mutex a pointer but can't take it out of the object. The real problem: Free can't be done holding the lock because, then memory occupied by the lock is also lost.