×

System and method for implementing NUMA-aware reader-writer locks

  • US 8,966,491 B2
  • Filed: 04/27/2012
  • Issued: 02/24/2015
  • Est. Priority Date: 04/27/2012
  • Status: Active Grant
First Claim
Patent Images

1. A method, comprising:

  • performing, by a computer;

    beginning execution of a multithreaded application that comprises one or more requests to acquire a shared lock, wherein the shared lock controls write access to a critical section of code or a shared resource by concurrently executing threads of the multithreaded application, wherein only one thread of the multithreaded application can hold the shared lock for writing at a time, wherein each of the concurrently executing threads of the multithreaded application executes on one of a plurality of processor cores in a cluster of processor cores that is one of a plurality of clusters of processor cores on which the concurrently executing threads of the multithreaded application are executing, and wherein the plurality of processor cores in each of the clusters of processor cores share a memory;

    a reader thread of the multithreaded application;

    determining that no thread holds the shared lock for writing; and

    in response to determining that no thread holds the shared lock for writing;

    accessing the critical section of code or shared resource in read-only mode;

    subsequent to the reader thread of the multithreaded application accessing the critical section of code or shared resource in read-only mode, a writer thread of the multithreaded application acquiring ownership of a cluster specific lock for writing, and in response to the writer thread of the multithreaded application acquiring ownership of the cluster-specific lock for writing, acquiring the shared lock for writing;

    in response to acquiring the shared lock for writing, the writer thread of the multithreaded application;

    accessing the critical section of code or shared resource for writing; and

    subsequent to said accessing the critical section of code or shared resource for writing;

    determining whether at least one other thread of the multithreaded application executing on a processor core in the cluster of processor cores that comprises the processor core on which the writer thread of the multithreaded application is executing is waiting to acquire the shared lock for writing; and

    in response to determining that at least one other thread of the multithreaded application executing on a processor core in the cluster of processor cores that comprises the processor core on which the writer thread of the multithreaded application is executing is waiting to acquire the shared lock for writing, passing ownership of the cluster-specific lock for writing to one of the at least one other threads of the multithreaded application executing on a processor core in the cluster of processor cores that comprises the processor core on which the writer thread of the multithreaded application is executing that is waiting to acquire the shared lock for writing without releasing the shared lock.

View all claims
  • 1 Assignment
Timeline View
Assignment View
    ×
    ×