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
029a1103
There was an error fetching the commit references. Please try again later.
Commit
029a1103
authored
8 years ago
by
Subv
Browse files
Options
Downloads
Patches
Plain Diff
Timers: Immediately signal the timer if it was started with an initial value of 0.
parent
e594e63b
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/timer.cpp
+23
-16
23 additions, 16 deletions
src/core/hle/kernel/timer.cpp
src/core/hle/kernel/timer.h
+8
-0
8 additions, 0 deletions
src/core/hle/kernel/timer.h
with
31 additions
and
16 deletions
src/core/hle/kernel/timer.cpp
+
23
−
16
View file @
029a1103
...
...
@@ -52,9 +52,14 @@ void Timer::Set(s64 initial, s64 interval) {
initial_delay
=
initial
;
interval_delay
=
interval
;
u64
initial_microseconds
=
initial
/
1000
;
CoreTiming
::
ScheduleEvent
(
usToCycles
(
initial_microseconds
),
timer_callback_event_type
,
callback_handle
);
if
(
initial
==
0
)
{
// Immediately invoke the callback
Signal
(
0
);
}
else
{
u64
initial_microseconds
=
initial
/
1000
;
CoreTiming
::
ScheduleEvent
(
usToCycles
(
initial_microseconds
),
timer_callback_event_type
,
callback_handle
);
}
}
void
Timer
::
Cancel
()
{
...
...
@@ -72,6 +77,20 @@ void Timer::WakeupAllWaitingThreads() {
signaled
=
false
;
}
void
Timer
::
Signal
(
int
cycles_late
)
{
LOG_TRACE
(
Kernel
,
"Timer %08"
PRIx64
" fired"
,
timer_handle
);
// Resume all waiting threads
WakeupAllWaitingThreads
();
if
(
interval_delay
!=
0
)
{
// Reschedule the timer with the interval delay
u64
interval_microseconds
=
interval_delay
/
1000
;
CoreTiming
::
ScheduleEvent
(
usToCycles
(
interval_microseconds
)
-
cycles_late
,
timer_callback_event_type
,
callback_handle
);
}
}
/// The timer callback event, called when a timer is fired
static
void
TimerCallback
(
u64
timer_handle
,
int
cycles_late
)
{
SharedPtr
<
Timer
>
timer
=
...
...
@@ -82,19 +101,7 @@ static void TimerCallback(u64 timer_handle, int cycles_late) {
return
;
}
LOG_TRACE
(
Kernel
,
"Timer %08"
PRIx64
" fired"
,
timer_handle
);
timer
->
signaled
=
true
;
// Resume all waiting threads
timer
->
WakeupAllWaitingThreads
();
if
(
timer
->
interval_delay
!=
0
)
{
// Reschedule the timer with the interval delay
u64
interval_microseconds
=
timer
->
interval_delay
/
1000
;
CoreTiming
::
ScheduleEvent
(
usToCycles
(
interval_microseconds
)
-
cycles_late
,
timer_callback_event_type
,
timer_handle
);
}
timer
->
Signal
(
cycles_late
);
}
void
TimersInit
()
{
...
...
This diff is collapsed.
Click to expand it.
src/core/hle/kernel/timer.h
+
8
−
0
View file @
029a1103
...
...
@@ -54,6 +54,14 @@ public:
void
Cancel
();
void
Clear
();
/**
* Signals the timer, waking up any waiting threads and rescheduling it
* for the next interval.
* This method should not be called from outside the timer callback handler,
* lest multiple callback events get scheduled.
*/
void
Signal
(
int
cycles_late
);
private
:
Timer
();
~
Timer
()
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