mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-27 08:46:03 +03:00
[PR #600] [MERGED] kernel: Reimplement POSIX semaphores using std::counting_semaphore. #1660
Labels
No labels
Bloodborne
bug
contributor wanted
documentation
enhancement
frontend
good first issue
help wanted
linux
pull-request
question
release
verification progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shadPS4#1660
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/shadps4-emu/shadPS4/pull/600
Author: @squidbus
Created: 8/26/2024
Status: ✅ Merged
Merged: 8/28/2024
Merged by: @raphaelthegreat
Base:
main← Head:posix-sem📝 Commits (1)
8ac7345kernel: Reimplement POSIX semaphores using std::counting_semaphore.📊 Changes
3 files changed (+77 additions, -67 deletions)
View changed files
📝
CMakeLists.txt(+0 -4)📝
src/core/libraries/kernel/thread_management.cpp(+70 -63)📝
src/core/libraries/kernel/thread_management.h(+7 -0)📄 Description
Reimplements POSIX semaphores using
std::counting_semaphoreas a more cross-platform solution. Each function does error checking as defined by the POSIX spec.For Windows this reduces reliance on winpthreads, and for macOS this fixes POSIX semaphores as apparently
sem_init,sem_destroy, andsem_getvalueare not only marked as deprecated but also not implemented; only named POSIX semaphores are implemented.One caveat is that
std::counting_semaphoredoes not provide an equivalent forsem_getvalue. Instead we keep an atomic counter alongside the semaphore to track its value based on successful waits and posts.Tested this on the Persona Dancing games and it resolves the issue I was having on macOS where the games would crash on launch. The invalid semaphores make the games' job threads think there is work to do as they do not properly check for errors, resulting in a jump to a null pointer.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.