Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Register
  • Sign in
  • G GLib
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 855
    • Issues 855
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 48
    • Merge requests 48
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Container Registry
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • GNOMEGNOME
  • GLib
  • Merge requests
  • !2768

gthread-posix: Add a native implementation for GRecMutex to use atomics

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Marco Trevisan requested to merge 3v1n0/glib:atomic-rec-mutex into main Jun 23, 2022
  • Overview 7
  • Commits 3
  • Pipelines 6
  • Changes 2

Implement GRecMutex using atomic logic, without dealing with mutex, but still avoid using pure spin-locking when there's contention by using a futex wait as we do with the GMutex.

As per this we can avoid further allocations and using syscalls in most of scenarios where it's just enough to check for an atomic value.

This also opens the gates to implementing a native version of GCond for it.


By doing some quick benchmarks I'm also wondering if it could be even better to just yielding the waiting threads at all, without going through futex (like in 3v1n0/glib@01f25886)... As it seems to perform better, but indeed that would imply waking up threads that have no way to enter in a critical section just for spinning again...

Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: atomic-rec-mutex