Results 1 to 10 of 10

Thread: QReadWriteLock Question

  1. #1
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default QReadWriteLock Question

    I'm using Win32 at the moment.

    Does the QReadWriteLock take up limited system resources (besides just the memory to hold the object), or can you use as many instances of these as you want (subject to same memory caveat)?

    In other words, do you need to use these locks as sparingly as possible, or can you feel free to get more granular to limit blocks when writing?

    Thanks

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QReadWriteLock Question

    Until the lock becomes effective (that is until some thread actually "hangs" on the lock) it's just a memory structure. Later it depends on the implementation of locking mechanisms on a particular platform.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QReadWriteLock Question

    Quote Originally Posted by wysota View Post
    Until the lock becomes effective (that is until some thread actually "hangs" on the lock) it's just a memory structure. Later it depends on the implementation of locking mechanisms on a particular platform.
    Is it also just a memory structure after unlock? The actual time of the lock won't be long and it'll tend to be infrequent. Although I'm thinking of using many read write locks, they won't be locked at the same time.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QReadWriteLock Question

    Quote Originally Posted by qtYoda View Post
    Is it also just a memory structure after unlock?
    No, I don't think so. Once the semaphore is allocated it probably stays allocated until the object is destroyed. But you can verify that in the source code.

    How many locks are we talking about? 1000? more?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QReadWriteLock Question

    Quote Originally Posted by wysota View Post
    No, I don't think so. Once the semaphore is allocated it probably stays allocated until the object is destroyed. But you can verify that in the source code.

    How many locks are we talking about? 1000? more?
    Probably around 5000, but how many would actually be utilized, or even allocated would depend on the session. Probably not often near than many.

    As followup, I was going to put the lock around a collection at the hash bucket level, rather than lock the whole collection when adding or removing. So there would be 1 per bucket.

    Should I (or is it possible) just to have a semaphore that holds the read/write locks. I doubt I'd run into many instances of a lot of simultaneous writes to the collection.

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QReadWriteLock Question

    It's easiest to just try and see.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  7. #7
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QReadWriteLock Question

    Quote Originally Posted by wysota View Post
    It's easiest to just try and see.
    Yeah, I know. I've got to get my debugger situation squared away. Right now its incredibly limited.

    Are there any white papers on setting up a good multithreaded debugging system with Qt Creator and VisualStudio 2010?

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QReadWriteLock Question

    What's wrong with using gdb?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  9. #9
    Join Date
    Aug 2010
    Posts
    28
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QReadWriteLock Question

    Well, I'm new to c++, visual studio, Qt, Qt creator and coding multi-threaded applications --- should I add GDB to that too? Is there any books/papers on how to setup gdb with Qt/VS2010 to debug?

  10. #10
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,017 Times in 4,793 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QReadWriteLock Question

    You don't have to setup anything. Actually if you're using VS2010 and MSVC then you should use the native Visual Studio debugger. Just click on the "Debug"
    button in the IDE to start debugging. You might want to set some breakpoints first.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. using QReadWriteLock in QMap and Qhash
    By HERC in forum Qt Programming
    Replies: 0
    Last Post: 1st July 2010, 13:00
  2. css question
    By Hardstyle in forum Newbie
    Replies: 1
    Last Post: 29th June 2010, 05:29
  3. rcc question
    By mojo2000 in forum Newbie
    Replies: 13
    Last Post: 18th November 2009, 22:26
  4. Qwt question
    By baray98 in forum Qwt
    Replies: 3
    Last Post: 26th November 2007, 20:31
  5. VTK question
    By magland in forum General Programming
    Replies: 0
    Last Post: 9th May 2007, 20:47

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.