Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8216258

Make FreeIdSet semaphore-based

    XMLWordPrintable

Details

    • gc
    • b06
    • generic
    • generic

    Description

      The FreeIdSet currently uses a monitor to protect its data structure manipulations and to wait/notify when more threads want to allocate an id than there are available. Worse, the notification is a notify_all. Even worse, the monitor used is the CBL monitor, so locking here contends with CBL enqueue/get.

      A different approach would be to use a counting semaphore to control access to the set. That's a more natural approach, but couldn't be done when the FreeIdSet was developed because we didn't have an API for semaphores then. Also need to make the id set manipulation lock free. That can be done by making the "head" value a pair of bit fields, the next available index and an update counter. The update counter is incremented on each change of head, so solve the ABA problem.

      Attachments

        Activity

          People

            kbarrett Kim Barrett
            kbarrett Kim Barrett
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: