[haiku-commits] Re: r34395 - in haiku/trunk/src/libs/compat/freebsd_network: . compat/sys

  • From: Colin Günther <coling@xxxxxx>
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Tue, 01 Dec 2009 15:51:56 +0100

Ingo Weinhold schrieb:
On 2009-11-30 at 23:27:02 [+0100], coling@xxxxxx wrote:
Author: colin
Date: 2009-11-30 23:27:02 +0100 (Mon, 30 Nov 2009)
New Revision: 34395
Changeset: http://dev.haiku-os.org/changeset/34395/haiku
[...]
Modified: haiku/trunk/src/libs/compat/freebsd_network/compat/sys/condvar.h
===================================================================
--- haiku/trunk/src/libs/compat/freebsd_network/compat/sys/condvar.h 2009-11-30 22:07:16 UTC (rev 34394) +++ haiku/trunk/src/libs/compat/freebsd_network/compat/sys/condvar.h 2009-11-30 22:27:02 UTC (rev 34395)
@@ -10,7 +10,7 @@
struct cv {
-    int cv_waiters;
+    int dummy;
 };

It's still not much clearer to me, why you use this structure.
The "struct cv" is needed to stay source compatible with FreeBSD wlan stack. For example http://dev.haiku-os.org/browser/haiku/trunk/src/libs/compat/freebsd_wlan/net80211/ieee80211_scan.c#L62 this structure is defined and used throughout this file.
Unless you really need uninit_condition_variables() to destroy condition variables -- which doesn't look like it from what I see --
Mmh, so I thought

while (variable != NULL) {
        ConditionVariable* next = definition.GetLink(variable);
        variable->Unpublish();
        delete variable;


in uninit_condition_variables() destroys the ConditionVariables. Do I miss something here?
I would simply get rid of the hash table, add the ConditionVariable pointer back to the cv structure (well, you could as well get rid of the structure as well
I'd like to get rid of the hash table and the tracking of used ConditionVariables, too. But the functions in Condvar.cpp are intended to support two use cases: 1) Implementing FreeBSDs condition variable subsystem (this is the one which needs the "struct cv") 2) Implementing FreeBSDs synchronization subsystem (http://dev.haiku-os.org/browser/haiku/trunk/src/libs/compat/freebsd_network/synch.c)

The hash table is really needed for Use Case 2) function wakeup. So that I can retrieve the ConditionVariable belonging to this identifier. A typical use case for the synchronization subsystem can be found here (http://dev.haiku-os.org/browser/haiku/trunk/src/add-ons/kernel/drivers/network/wlan/iprowifi2200/dev/iwi/if_iwi.c#L2485) where msleep is used to wait for firmware initialization for 1 s at most. In the same file wakeup (http://dev.haiku-os.org/browser/haiku/trunk/src/add-ons/kernel/drivers/network/wlan/iprowifi2200/dev/iwi/if_iwi.c#L1675) is called with the same identifier used with msleep above resulting in continued execution of the code in msleep way before the 1s timed out.

To sum it up: The hash table is the best way I see to generalize the implementation of the 2 use cases.

and just use ConditionVariable pointers), and add static versions of the ConditionVariable::Notify{One,All}() methods that take the identifying object as first parameter.
Do you mean I should add static versions of ConditionVariable::Notify{One,All}() methods to Haiku's condition_variable.{h,cpp} ? I don't see such versions in the current source, at least.
CU, Ingo


Kind Regards
-Colin

Other related posts: