Re: dev_lock() question

From: John Baldwin (jhb_at_FreeBSD.org)
Date: 09/29/05

  • Next message: Robert Watson: "Re: freebsd-5.4-stable panics"
    To: freebsd-hackers@freebsd.org, Poul-Henning Kamp <phk@FreeBSD.org>
    Date: Thu, 29 Sep 2005 14:08:16 -0400
    
    

    On Thursday 29 September 2005 01:04 pm, Stanislav Sedov wrote:
    > On Thu, Sep 29, 2005 at 06:55:38PM +0200, Divacky Roman wrote:
    > > Hi,
    > >
    > > dev_lock() looks this way:
    > >
    > > void
    > > dev_lock(void)
    > > {
    > > if (!mtx_initialized(&devmtx))
    > > mtx_init(&devmtx, "cdev", NULL, MTX_DEF);
    > > mtx_lock(&devmtx);
    > > }
    > >
    > > I wonder why is the mtx_initialized checking necessary? shouldnt explicit
    > > initialization be sufficient?
    > >
    > > thnx for answer
    > >
    > > roman
    >
    > Moving "mtx_initialized()" check into mtx_init will decrease speed of other
    > mutexes initialization. We must check if it's initialized here because of
    > it's not permiited to pass already initialized mutex to mtx_init().

    Actually, you would think that it could be initialized either via an early
    SYSINIT() or in the init_mutexes() function in kern_mutex.c and thus not need
    the early check and avoid penalizing dev_lock().

    phk, how early his dev_lock needed?

    -- 
    John Baldwin <jhb@FreeBSD.org>  <><  http://www.FreeBSD.org/~jhb/
    "Power Users Use the Power to Serve"  =  http://www.FreeBSD.org
    _______________________________________________
    freebsd-hackers@freebsd.org mailing list
    http://lists.freebsd.org/mailman/listinfo/freebsd-hackers
    To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
    

  • Next message: Robert Watson: "Re: freebsd-5.4-stable panics"

    Relevant Pages

    • dev_lock() question
      ... initialization be sufficient? ... thnx for answer ...
      (freebsd-hackers)
    • Re: dev_lock() question
      ... > thnx for answer ... mutexes initialization. ...
      (freebsd-hackers)
    • Re: Does C# have static local variables like C++?
      ... void f ... static int count = 0; ... Another possibility is that static locals break the usual variable initialization paradigm. ...
      (microsoft.public.dotnet.languages.csharp)
    • Re: Getting a reference to caller object
      ... The invocation of 'main' will cause class initialization, ... stack frames, local variables in them, and "this" local to each stack ... void aa{ ... // THIS IS WHAT I WANT TO RETRIEVE, ...
      (comp.lang.java.programmer)
    • Re: Question on automatic variables and array arguments
      ... as i understand only global and static variables are initialized to ... Initialization of local variables would have to be done via ... void func1 ... I think func1 is equivalent to void func3(char *const str). ...
      (comp.lang.c)