FEX-Emu / FEX-Emu/FEX

shared_mutex with unique lock priority

Open
#1,687 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
8k
Forks
351
Avg merge
12h 31m
Merged PRs (30d)
102

Description

Having a shared lock where unique locks take priority would be beneficial.
std::shared_mutex gives shared locks priority when a shared lock is already held.

With a new lock with unique priority it should have the properties:

1. When a shared lock is already held and then a unique lock is attempting to be made
- Subsequent `try_lock_shared` should immediately return false even though unique_lock isn't held yet
- Subsequent `lock_shared` should block until unique lock is granted and relinquished
- If a subsequent unique lock is pending while a unique lock is already held then a shared lock shouldn't be able to win the contention.

Might be worth using `WFE/WFET` for faster userspace checking of lock if it is expected to not be contended for too long.

Contributor guide

Open the contributing guide

Research direction

Start by locating the shared mutex implementation and its uses in FEX, then review how std::shared_mutex currently handles shared and unique lock contention. Compare the implementation with the requested priority rules, including try_lock_shared, lock_shared, pending unique locks, and the possible WFE/WFET optimization; done means the requested unique-lock priority behavior is implemented and tested.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
operating-systems
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.