[ovs-dev] [PATCH 1/5] ovs-thread: Add a comment
yamamoto at valinux.co.jp
Wed Feb 5 02:47:17 UTC 2014
> On Wed, Jan 15, 2014 at 12:41:20PM +0900, YAMAMOTO Takashi wrote:
>> Add a comment about implicit synchronization which
>> fat-rwlock seems to rely on.
>> Signed-off-by: YAMAMOTO Takashi <yamamoto at valinux.co.jp>
>> lib/ovs-thread.h | 8 ++++++++
>> 1 file changed, 8 insertions(+)
>> diff --git a/lib/ovs-thread.h b/lib/ovs-thread.h
>> index 8cf2ecc..dab7510 100644
>> --- a/lib/ovs-thread.h
>> +++ b/lib/ovs-thread.h
>> @@ -447,6 +447,14 @@ void xpthread_join(pthread_t, void **);
>> * Compared to pthread_key_t, ovsthread_key_t has the follow limitations:
>> * - Destructors must not access thread-specific data (via ovsthread_key).
>> + *
>> + * Unlike pthread_key_t, this API implicitly serializes key removal
>> + * (ovsthread_key_delete) and thread exit. (destructor)
>> + * I.e.
>> + * - ovsthread_key_delete ensures the completion of destructors for
>> + * the key.
>> + * - Once ovsthread_key_delete completed, no destructors for the key
>> + * will be executed on thread exit.
>> typedef struct ovsthread_key *ovsthread_key_t;
> I think I understand what you are saying, but I think that I would
> phrase it differently. Does the following express what you mean?
> diff --git a/lib/ovs-thread.c b/lib/ovs-thread.c
> index a20b2fd..18e524e 100644
> --- a/lib/ovs-thread.c
> +++ b/lib/ovs-thread.c
> @@ -592,7 +592,8 @@ ovsthread_key_create(ovsthread_key_t *keyp, void (*destructor)(void *))
> /* Frees 'key'. The destructor supplied to ovsthread_key_create(), if any, is
> - * not called.
> + * not called. This function returns only after any running destructors for
> + * 'key' complete execution.
'running destructors' is not exact.
i believe pthread api allows for concurrent exiting threads to
start executing the destructor after pthread_key_delete completed.
but this ovsthread one doesn't. and fat-rwlock relies on it.
i think it's better to say the difference explicitly as
it guarantees more than pthread while using similar-looking names.
i was confused when reading fat-rwlock.
> * This function is similar to xpthread_key_delete(). */
> dev mailing list
> dev at openvswitch.org
More information about the dev