Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Suyu
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
many-archive
Suyu
Commits
dc70a87a
There was an error fetching the commit references. Please try again later.
Commit
dc70a87a
authored
6 years ago
by
Michael Scire
Browse files
Options
Downloads
Patches
Plain Diff
Kernel/Arbiters: HLE is atomic, adjust code to reflect that.
parent
8f8fe62a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/core/hle/kernel/address_arbiter.cpp
+13
-36
13 additions, 36 deletions
src/core/hle/kernel/address_arbiter.cpp
src/core/hle/kernel/thread.h
+0
-1
0 additions, 1 deletion
src/core/hle/kernel/thread.h
with
13 additions
and
37 deletions
src/core/hle/kernel/address_arbiter.cpp
+
13
−
36
View file @
dc70a87a
...
@@ -20,14 +20,14 @@ namespace Kernel {
...
@@ -20,14 +20,14 @@ namespace Kernel {
ResultCode
WaitForAddress
(
VAddr
address
,
s64
timeout
)
{
ResultCode
WaitForAddress
(
VAddr
address
,
s64
timeout
)
{
SharedPtr
<
Thread
>
current_thread
=
GetCurrentThread
();
SharedPtr
<
Thread
>
current_thread
=
GetCurrentThread
();
current_thread
->
arb_wait_address
=
address
;
current_thread
->
arb_wait_address
=
address
;
current_thread
->
arb_wait_result
=
RESULT_TIMEOUT
;
current_thread
->
status
=
THREADSTATUS_WAIT_ARB
;
current_thread
->
status
=
THREADSTATUS_WAIT_ARB
;
current_thread
->
wakeup_callback
=
nullptr
;
current_thread
->
wakeup_callback
=
nullptr
;
current_thread
->
WakeAfterDelay
(
timeout
);
current_thread
->
WakeAfterDelay
(
timeout
);
Core
::
System
::
GetInstance
().
CpuCore
(
current_thread
->
processor_id
).
PrepareReschedule
();
Core
::
System
::
GetInstance
().
CpuCore
(
current_thread
->
processor_id
).
PrepareReschedule
();
return
current_thread
->
arb_wait_result
;
// This should never actually execute.
return
RESULT_SUCCESS
;
}
}
// Gets the threads waiting on an address.
// Gets the threads waiting on an address.
...
@@ -67,7 +67,7 @@ namespace Kernel {
...
@@ -67,7 +67,7 @@ namespace Kernel {
// TODO: Rescheduling should not occur while waking threads. How can it be prevented?
// TODO: Rescheduling should not occur while waking threads. How can it be prevented?
for
(
size_t
i
=
0
;
i
<
last
;
i
++
)
{
for
(
size_t
i
=
0
;
i
<
last
;
i
++
)
{
ASSERT
(
waiting_threads
[
i
]
->
status
=
THREADSTATUS_WAIT_ARB
);
ASSERT
(
waiting_threads
[
i
]
->
status
=
THREADSTATUS_WAIT_ARB
);
waiting_threads
[
i
]
->
arb_wait_r
esult
=
RESULT_SUCCESS
;
waiting_threads
[
i
]
->
SetWaitSynchronizationR
esult
(
RESULT_SUCCESS
)
;
waiting_threads
[
i
]
->
arb_wait_address
=
0
;
waiting_threads
[
i
]
->
arb_wait_address
=
0
;
waiting_threads
[
i
]
->
ResumeFromWait
();
waiting_threads
[
i
]
->
ResumeFromWait
();
}
}
...
@@ -91,17 +91,9 @@ namespace Kernel {
...
@@ -91,17 +91,9 @@ namespace Kernel {
return
ERR_INVALID_ADDRESS_STATE
;
return
ERR_INVALID_ADDRESS_STATE
;
}
}
s32
cur_value
;
if
((
s32
)
Memory
::
Read32
(
address
)
==
value
)
{
// Get value, incrementing if equal.
Memory
::
Write32
(
address
,
(
u32
)(
value
+
1
));
{
}
else
{
// Increment if Equal must be an atomic operation.
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
HLE
::
g_hle_lock
);
cur_value
=
(
s32
)
Memory
::
Read32
(
address
);
if
(
cur_value
==
value
)
{
Memory
::
Write32
(
address
,
(
u32
)(
cur_value
+
1
));
}
}
if
(
cur_value
!=
value
)
{
return
ERR_INVALID_STATE
;
return
ERR_INVALID_STATE
;
}
}
...
@@ -128,18 +120,10 @@ namespace Kernel {
...
@@ -128,18 +120,10 @@ namespace Kernel {
}
else
{
}
else
{
updated_value
=
value
;
updated_value
=
value
;
}
}
s32
cur_value
;
// Perform an atomic update if equal.
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
HLE
::
g_hle_lock
);
cur_value
=
(
s32
)
Memory
::
Read32
(
address
);
if
(
cur_value
==
value
)
{
Memory
::
Write32
(
address
,
(
u32
)(
updated_value
));
}
}
// Only continue if equal.
if
((
s32
)
Memory
::
Read32
(
address
)
==
value
)
{
if
(
cur_value
!=
value
)
{
Memory
::
Write32
(
address
,
(
u32
)(
updated_value
));
}
else
{
return
ERR_INVALID_STATE
;
return
ERR_INVALID_STATE
;
}
}
...
@@ -154,17 +138,10 @@ namespace Kernel {
...
@@ -154,17 +138,10 @@ namespace Kernel {
return
ERR_INVALID_ADDRESS_STATE
;
return
ERR_INVALID_ADDRESS_STATE
;
}
}
s32
cur_value
;
s32
cur_value
=
(
s32
)
Memory
::
Read32
(
address
);
// Get value, decrementing if less than
if
(
cur_value
<
value
)
{
{
Memory
::
Write32
(
address
,
(
u32
)(
cur_value
-
1
));
// Decrement if less than must be an atomic operation.
}
else
{
std
::
lock_guard
<
std
::
recursive_mutex
>
lock
(
HLE
::
g_hle_lock
);
cur_value
=
(
s32
)
Memory
::
Read32
(
address
);
if
(
cur_value
<
value
)
{
Memory
::
Write32
(
address
,
(
u32
)(
cur_value
-
1
));
}
}
if
(
cur_value
>=
value
)
{
return
ERR_INVALID_STATE
;
return
ERR_INVALID_STATE
;
}
}
// Short-circuit without rescheduling, if timeout is zero.
// Short-circuit without rescheduling, if timeout is zero.
...
...
This diff is collapsed.
Click to expand it.
src/core/hle/kernel/thread.h
+
0
−
1
View file @
dc70a87a
...
@@ -233,7 +233,6 @@ public:
...
@@ -233,7 +233,6 @@ public:
// If waiting for an AddressArbiter, this is the address being waited on.
// If waiting for an AddressArbiter, this is the address being waited on.
VAddr
arb_wait_address
{
0
};
VAddr
arb_wait_address
{
0
};
ResultCode
arb_wait_result
{
RESULT_SUCCESS
};
///< Result returned when done waiting on AddressArbiter.
std
::
string
name
;
std
::
string
name
;
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment