Skip to content
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

As a firmware developer, I can specify code is executed without being interrupted #758

Closed
monkbroc opened this issue Dec 7, 2015 · 3 comments

Comments

@monkbroc
Copy link
Member

commented Dec 7, 2015

https://community.particle.io/t/system-thread-can-it-be-disabled-at-runtime/18075

For critical but long-ish bits of application code it would be useful to temporarily elevate the priority of the current thread.

Proposed API: Thread.elevatePriority should elevate the priority for the current block and restore it when falling out of scope.

@m-mcgowan

This comment has been minimized.

Copy link
Contributor

commented Jan 12, 2016

We have the CriticalSection RAII class, which stops thread scheduling but does't prevent interrupts. That would seem to cater for this need without having to juggle priorities?

I'm not entirely happy with my initially calling this CriticalSection since while it does exclude other threads from entering that section of code, it does it in a very specific way. I think I'd prefer to rename it SingleThreadedSection to more accurately describe the mechanics of what is happening.

I can envisage a family of xxxSection classes for different levels of exclusivity:

  • SingleThreadedSection - disables thread scheduling but not interrupts for the current code block
  • AtomicSection - disables thread scheduling and interrupts for the current code block
  • PrioritySection - raises the priority of the current thread above background threads (but allowing critical services to still run.)
  • CriticalSection will then be repurposed to be a traditional critical section involving mutexes which doesn't alter any scheduling or interrupts.

I'd also like to make sure that whatever we use can be easily migrated to the Wiring++ API (or that we use Wiring++ spec from the start.)

@m-mcgowan m-mcgowan changed the title Implement Thread.elevatePriority As a firmware developer, I can specify code is executed without being interrupted Jan 12, 2016

@monkbroc

This comment has been minimized.

Copy link
Member Author

commented Jan 12, 2016

Well reasoned. This is only one part of the discussion on the threading API.

@m-mcgowan m-mcgowan added this to the 0.4.9 milestone Jan 17, 2016

m-mcgowan added a commit that referenced this issue Jan 18, 2016
@m-mcgowan

This comment has been minimized.

Copy link
Contributor

commented Jan 21, 2016

We'll come back and look at thread priority as a separate feature in conjunction with reviewing Thread class API.

@m-mcgowan m-mcgowan closed this Jan 21, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.