Re: Member variable locking (Critical Section)

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



I tend to use a pool of critical sections and use a hash of something
related to the socket (or whatever) to determine which critical
section is associated with which socket; you just do the hash once
when the socket requests a critical section and the 'lock factory'
determines which one to give it. You can then tune the parameters to
your lock factory to determine the most efficient pool size and
profile the hash to ensure good distribution. You need to remember
that you're trading potential lock contention for reduced resource
consumption and then profile the server to tune. If you find that
cross socket lock contention is a major issue then you can simply plug
in a lock factory that gives out unique locks...

--
Len Holgate
http://www.lenholgate.com

On 20 Sep, 12:05, "Kürþat" <x...@xxxxxx> wrote:
Hi,

I have a IOCP based socket server. I instantiate a context object for all
connected clients and put them into an array. Some member variables of
context objects can be accessed out of the IOCP worker threads. So I should
implement a locking mechanism to sync access to those members. I plan to use
accessor methods and critical sections for this purpose but number of
context objects is between 3000-10000. Is it reasonable to initialize 10000
critical sections in a process considering resource issues?Is there any
better solution?

Thanks in advance.


.



Relevant Pages

  • Re: [RFC] Use RCU for tcp_ehash lookup
    ... > the hash bucket locks. ... > parallel to socket input packet processing. ... Such workloads would benefit from the lock-free lookup. ...
    (Linux-Kernel)
  • Re: convert fd to IO object in extension?
    ... Since both Socket and File are subclasses of IO, ... What I meant was that I'd have to maintain a Hash mapping fd's to IO ... module EpollExt ... automatically call the cleanup method in the associated Epoll object. ...
    (comp.lang.ruby)
  • Re: Custom Thread Pool (by Mr. Jon Skeet) Enhancement
    ... Essentially it receives short socket based ... > connections with an ASCII message, parses that message, does some ... Could you not use asychronous IO again, and keep the thread pool ... Check on completion of a work item the CPU usage and decide whether ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: [RFC][PATCH 0/3] TCP/IP Critical socket communication mechanism
    ... >> pool when the allocation happens in the device driver and we have no ... >> idea which socket the packet is destined for? ...
    (Linux-Kernel)
  • Re: Available memory and limit on thread creation
    ... >>to send the results back to the correct socket. ... > step of the exec stream you send a packet back to a common port where ... > the packet contain nothing but the id number of the exec. ... purpose socket readers in a pool, another pool to process the received ...
    (comp.lang.java.programmer)