Skip to content

machine: [rp2] discount scheduling delays in I2C timeouts #4876

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

eliasnaur
Copy link
Contributor

@eliasnaur eliasnaur commented Apr 29, 2025

The gosched call introduces arbitrary long delays in general, and in TinyGo particular because the goroutine scheduler is cooperative and doesn't preempt busy (e.g. compute-heavy) goroutines. This change discounts such delays from the rp2xxx I2C timeout logic.

I tested this change by simulating a busy goroutine:

go func() {
	for {
		// Busy.
		before := time.Now()
		for time.Since(before) < 100*time.Millisecond {
		}
		// Sleep.
		time.Sleep(100 * time.Millisecond)
	}
}()

and testing that I2C transfers would no longer time out.

The `gosched` call introduce arbitrary long delays in general, and in
TinyGo particular because the goroutine scheduler is cooperative and
doesn't preempt busy (e.g. compute-heavy) goroutines.
This change discounts such delays from the rp2xxx I2C timeout logic.

I tested this change by simulating a busy goroutine:

	go func() {
		for {
      // Busy.
			before := time.Now()
			for time.Since(before) < 100*time.Millisecond {
			}
      // Sleep.
			time.Sleep(100 * time.Millisecond)
		}
	}()

and testing that I2C transfers would no longer time out.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant