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
6ea8b3ef
There was an error fetching the commit references. Please try again later.
Commit
6ea8b3ef
authored
6 years ago
by
bunnei
Browse files
Options
Downloads
Patches
Plain Diff
thread: Implement ChangeCore function.
parent
1c36f2a7
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/thread.cpp
+52
-1
52 additions, 1 deletion
src/core/hle/kernel/thread.cpp
src/core/hle/kernel/thread.h
+6
-0
6 additions, 0 deletions
src/core/hle/kernel/thread.h
with
58 additions
and
1 deletion
src/core/hle/kernel/thread.cpp
+
52
−
1
View file @
6ea8b3ef
...
@@ -273,7 +273,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
...
@@ -273,7 +273,7 @@ ResultVal<SharedPtr<Thread>> Thread::Create(std::string name, VAddr entry_point,
thread
->
name
=
std
::
move
(
name
);
thread
->
name
=
std
::
move
(
name
);
thread
->
callback_handle
=
wakeup_callback_handle_table
.
Create
(
thread
).
Unwrap
();
thread
->
callback_handle
=
wakeup_callback_handle_table
.
Create
(
thread
).
Unwrap
();
thread
->
owner_process
=
owner_process
;
thread
->
owner_process
=
owner_process
;
thread
->
scheduler
=
Core
::
System
().
GetInstance
().
Scheduler
(
static_cast
<
size_t
>
(
processor_id
)
)
;
thread
->
scheduler
=
Core
::
System
().
GetInstance
().
Scheduler
(
processor_id
);
thread
->
scheduler
->
AddThread
(
thread
,
priority
);
thread
->
scheduler
->
AddThread
(
thread
,
priority
);
// Find the next available TLS index, and mark it as used
// Find the next available TLS index, and mark it as used
...
@@ -415,6 +415,57 @@ void Thread::UpdatePriority() {
...
@@ -415,6 +415,57 @@ void Thread::UpdatePriority() {
lock_owner
->
UpdatePriority
();
lock_owner
->
UpdatePriority
();
}
}
static
s32
GetNextProcessorId
(
u64
mask
)
{
s32
processor_id
{};
for
(
s32
index
=
0
;
index
<
Core
::
NUM_CPU_CORES
;
++
index
)
{
if
(
mask
&
(
1ULL
<<
index
))
{
if
(
!
Core
::
System
().
GetInstance
().
Scheduler
(
index
)
->
GetCurrentThread
())
{
// Core is enabled and not running any threads, use this one
return
index
;
}
// Core is enabled, but running a thread, less ideal
processor_id
=
index
;
}
}
return
processor_id
;
}
void
Thread
::
ChangeCore
(
u32
core
,
u64
mask
)
{
const
s32
new_processor_id
{
GetNextProcessorId
(
mask
)};
ASSERT
(
ideal_core
==
core
);
// We're not doing anything with this yet, so assert the expected
ASSERT
(
new_processor_id
<
Core
::
NUM_CPU_CORES
);
if
(
new_processor_id
==
processor_id
)
{
// Already running on ideal core, nothing to do here
return
;
}
ASSERT
(
status
!=
THREADSTATUS_RUNNING
);
// Unsupported
processor_id
=
new_processor_id
;
ideal_core
=
core
;
mask
=
mask
;
// Add thread to new core's scheduler
auto
&
next_scheduler
=
Core
::
System
().
GetInstance
().
Scheduler
(
new_processor_id
);
next_scheduler
->
AddThread
(
this
,
current_priority
);
if
(
status
==
THREADSTATUS_READY
)
{
// If the thread was ready, unschedule from the previous core and schedule on the new core
scheduler
->
UnscheduleThread
(
this
,
current_priority
);
next_scheduler
->
ScheduleThread
(
this
,
current_priority
);
}
// Remove thread from previous core's scheduler
scheduler
->
RemoveThread
(
this
);
// Change thread's scheduler
scheduler
=
next_scheduler
;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
/**
...
...
This diff is collapsed.
Click to expand it.
src/core/hle/kernel/thread.h
+
6
−
0
View file @
6ea8b3ef
...
@@ -120,6 +120,9 @@ public:
...
@@ -120,6 +120,9 @@ public:
/// Recalculates the current priority taking into account priority inheritance.
/// Recalculates the current priority taking into account priority inheritance.
void
UpdatePriority
();
void
UpdatePriority
();
/// Changes the core that the thread is running or scheduled to run on.
void
ChangeCore
(
u32
core
,
u64
mask
);
/**
/**
* Gets the thread's thread ID
* Gets the thread's thread ID
* @return The thread's ID
* @return The thread's ID
...
@@ -244,6 +247,9 @@ public:
...
@@ -244,6 +247,9 @@ public:
std
::
shared_ptr
<
Scheduler
>
scheduler
;
std
::
shared_ptr
<
Scheduler
>
scheduler
;
u32
ideal_core
{
0xFFFFFFFF
};
u64
mask
{
0x1
};
private
:
private
:
Thread
();
Thread
();
~
Thread
()
override
;
~
Thread
()
override
;
...
...
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