Comments (2)
What would be the expected behavior?
If you specify a value that's lower than the timer callback processing time (including overhead) there are basically two options: we either ignore it (like we do now), or respect it and go into infinite loop where as soon as we exit an interrupt we must retrigger it.
from libdragon.
I would expect continuous/one-shot timers to run as soon/quick as possible
For continuous timers, it would mean I would expect a "freeze" from the timer interrupt not giving the cpu any chance to do anything useful
In that case it may be better to abort when a low-period continous timer is started
For one-shot timers, I do think it would make sense that the timer just runs as soon as possible, since it seems like a valid use case, for example imagine some code computes the ticks to wait until the next event and just happens to compute 100 ticks, then the timer never executing would be quite problematic
Suggested fixes (various ideas):
- At the very least mention in the docs that low ticks period values should be avoided (timers wouldn't run)
- abort when a small ticks value is used
- use max(ticks, 10000) instead of the provided ticks in the new_timer function
- have new_timer explicitly able to fail to start a timer, and fail to start a timer when the ticks value is low (but I'm not a fan because it leaves error checking to the user)
- allow the user to choose among the above:
->
timer_link_t* new_timer(int ticks, int flags, timer_callback1_t callback);
Or add those to timer flags (TF_) instead idkenum timer_check_mode { TCM_NONE, // don't check the timer ticks value, timer may not run if ticks too small TCM_CLAMP, // use max(ticks, 10000), "guarantees" (?) the timer will run but slower than expected ... }; timer_link_t* new_timer_check_ticks(int ticks, int flags, timer_callback1_t callback, enum timer_check_mode checkMode); #define new_timer(ticks, flags, callback) new_timer_check_ticks(ticks, flags, callback, TCM_NONE)
from libdragon.
Related Issues (20)
- Pre computed display lists HOT 7
- backtrace.c doesn't handle correctly 64-bit addresses
- Hello world HOT 1
- Can't draw sprite with rdp unless drawing in software first HOT 2
- ARM platforms not supported in the Dockerfiles on GHCR HOT 3
- [preview] RSP crash (?) with an extremely simple rom using rdpq
- [preview] rdpq validator validates tile for tex0 even if the combiner does not use it HOT 1
- [preview] new joypad library does not work on iQue HOT 1
- [preview] emit an assert when using Opus on a mixer channel not ready for 48 Khz HOT 1
- Add an assertion when using old-school sprite loading with compressed sprites HOT 1
- [preview] regression in mixer causes audio playback issues with XM64 HOT 1
- stat() doesn't work on directories HOT 1
- argument 1 value ‘18446744073709551611’ exceeds maximum object size 9223372036854775807 HOT 1
- Reading directory contents from sdcard on flash cartdrige HOT 4
- identify_accessory() identifies controller pak as rumble pak HOT 6
- Random Crashes / corruptions when using simple ucode
- Backtrace broken in case exception is triggered in tail call
- Missing examples (good first issue!) HOT 2
- rdpq_sprite_blit crop doesn't work with flipping
- PAL50 resolutions are letterboxed
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libdragon.