mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2026-04-26 00:05:58 +03:00
[PR #1440] [MERGED] kernel: Rewrite pthread emulation #2110
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#2110
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/1440
Author: @raphaelthegreat
Created: 10/23/2024
Status: ✅ Merged
Merged: 11/21/2024
Merged by: @raphaelthegreat
Base:
main← Head:more-kernel📝 Commits (10+)
8860a0blibkernel: Cleanup some function placesc878e69kernel: Refactor thread functions00b84b2kernel: It buildsd0d8b5ekernel: Fix a bunch of bugs, kernel thread heap77ff429kernel: File cleanup pt13771a65File cleanup pt2f635043File cleanup pt3ad8a202File cleanup pt4ef3341ckernel: Add missing funcscef37bekernel: Add basic exceptions for linux📊 Changes
104 files changed (+5511 additions, -3936 deletions)
View changed files
📝
CMakeLists.txt(+33 -20)📝
src/common/debug.h(+1 -1)➕
src/common/slab_heap.h(+163 -0)📝
src/common/slot_vector.h(+0 -3)➕
src/common/spin_lock.cpp(+53 -0)➕
src/common/spin_lock.h(+33 -0)📝
src/core/address_space.cpp(+139 -69)📝
src/core/debug_state.cpp(+1 -1)➕
src/core/file_sys/file.cpp(+114 -0)📝
src/core/libraries/audio3d/audio3d.cpp(+4 -4)📝
src/core/libraries/audio3d/audio3d_impl.cpp(+1 -1)📝
src/core/libraries/avplayer/avplayer.cpp(+3 -7)📝
src/core/libraries/avplayer/avplayer.h(+2 -2)📝
src/core/libraries/avplayer/avplayer_common.cpp(+5 -13)📝
src/core/libraries/avplayer/avplayer_common.h(+4 -6)📝
src/core/libraries/avplayer/avplayer_file_streamer.cpp(+3 -7)📝
src/core/libraries/avplayer/avplayer_file_streamer.h(+2 -4)📝
src/core/libraries/avplayer/avplayer_impl.cpp(+11 -26)📝
src/core/libraries/avplayer/avplayer_impl.h(+2 -6)📝
src/core/libraries/avplayer/avplayer_source.cpp(+13 -33)...and 80 more files
📄 Description
The current implementation of pthreads uses winpthreads on windows and pthread lib on linux. While it has served its purpose for quick prototyping, the code at the moment is very unorganized and messy. The emulator does not perform a lot of necessary checks to validate state. Note: This is linux only and draft at the moment
This has been in works for a while but aims to fully rewrite pthread primitives such as mutexes, condvars, rwlocks and threads to be accurate to the real freebsd libthr library. Thus we dont depend on an old library for it and have more control.
TLS allocation is now performed by the caller thread, while the target thread simply sets the guest tcb. This means that calling guest code from host threads is a bit more tricky as we can't easily setup TLS without the help of the kernel. For this a Thread class has been added in kernel which mimics an std::jthread like interface and uses pthread call underneath. This is useful for avplayer HLE.
Thread stack allocation is also implemented but not wired up yet as it needs to more testing. This may help games like TLOU2 that query thread stacks from the memory system.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.