Skip to content

threads: introduce new state #4102

@IldarValiev

Description

@IldarValiev

I suggest to introduce new state for threads STATUS_WAITING. This status will be considered in the "runqueue" group and will be used in cases when a thread have to wait a flag to be set.

Currently, in such cases threads are polling this flag without yielding control to another threads. My suggestion is to save the flag pointer, the mask and the result which are expected to be achieved after masking of the flag. Than thread will yield control to another thread. When his turn comes again, scheduler will check if the condition is fulfilled (flag & mask == result) and then enter this thread or skip it in other case.

Pros:

  • While a thread is waiting his flag to be set, it can yield control to other threads;
  • Thread supervisor can be implemented to monitor other threads and restart them if they are hung (some kind of a soft watchdog);
  • ... ?

Cons:

  • Little bit more complicated scheduler;
  • Performance penalty in case of short delays (especially for transceivers);
  • ... ?

Metadata

Metadata

Assignees

Labels

Area: coreArea: RIOT kernel. Handle PRs marked with this with care!Discussion: RFCThe issue/PR is used as a discussion starting point about the item of the issue/PRType: new featureThe issue requests / The PR implemements a new feature for RIOT

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions