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

Add and update Timer requirements #75

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

simhein
Copy link
Collaborator

@simhein simhein commented Jun 26, 2024

Add new Timers system requirements.
Remove user story from the system requirements.

Add new software timers requirements.
Regenerate the software requirements UIDs

@simhein simhein added the Requirements Requirements work label Jun 26, 2024
@simhein simhein requested review from nashif and a team June 26, 2024 18:28
@simhein simhein linked an issue Jun 27, 2024 that may be closed by this pull request
3 tasks
Copy link

@tobiaskaestner tobiaskaestner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left a couple of comments and suggestions with the proposed changes.
There are only a couple of additional things I want to mention here>

  1. The function where the application can query the next expiry time in systicks is not covered.
  2. Do we need to specify how users can influence a timer's resolution (in ns/ms/whatever) ?
  3. For the thread syncing functionality do we need to allow for more than one thread that can synchronize with a given timer?

<<<
USER_STORY: >>>
As a Zephyr RTOS user, I want to be able to track the passed real time in the OS with a dedicated hardware counter and interrupt.
The Zephyr RTOS shall provide a mechanism to define and initialize a timer at run time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
The Zephyr RTOS shall provide a mechanism to define and initialize a timer at run time.
The Zephyr RTOS shall provide a mechanism to define and initialize timers at run time.

TITLE: Call functions in interrupt context
TITLE: Timer definition at compile time
STATEMENT: >>>
The Zephyr RTOS shall provide a mechanism to define and initialize a timer at compile time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
The Zephyr RTOS shall provide a mechanism to define and initialize a timer at compile time.
The Zephyr RTOS shall provide a mechanism to define and initialize timers at compile time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

** nitpick **:

A technically more precise term is probably static initialization

docs/software_requirements/timers.sdoc Show resolved Hide resolved
docs/software_requirements/timers.sdoc Show resolved Hide resolved
docs/software_requirements/timers.sdoc Outdated Show resolved Hide resolved
STATUS: Draft
TYPE: Functional
COMPONENT: Timers
TITLE: Timer remaining expiration system tick time

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
TITLE: Timer remaining expiration system tick time
TITLE: Provide timer remaining expiration time in units of system ticks

STATUS: Draft
TYPE: Functional
COMPONENT: Timers
TITLE: Timer remaining expiration time

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
TITLE: Timer remaining expiration time
TITLE: Provide timer remaining expiration time in milliseconds

COMPONENT: Timers
TITLE: Timer remaining expiration time
STATEMENT: >>>
The Zephyr RTOS shall provide a mechanism to get the timer remaining until expiration time in milliseconds.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion:

Suggested change
The Zephyr RTOS shall provide a mechanism to get the timer remaining until expiration time in milliseconds.
The Zephyr RTOS shall provide a mechanism to get the timer's remaining time until its next expiry in milliseconds.

docs/software_requirements/timers.sdoc Outdated Show resolved Hide resolved
docs/software_requirements/timers.sdoc Outdated Show resolved Hide resolved
@simhein simhein force-pushed the timers_req branch 2 times, most recently from 7861f70 to bffab9a Compare July 9, 2024 15:13
@simhein
Copy link
Collaborator Author

simhein commented Jul 9, 2024

I left a couple of comments and suggestions with the proposed changes. There are only a couple of additional things I want to mention here>

1. The function where the application can query the next expiry time in systicks is not covered.

Added.

2. Do we need to specify how users can influence a timer's resolution (in ns/ms/whatever) ?

I think that could be specified but i don't see it here for the feature timer. because it don't give options to influence a timers resolution.

3. For the thread syncing functionality do we need to allow for more than one thread that can synchronize with a given timer?

Yes that is the way it is implemented as far as I see.

COMPONENT: Timers
TITLE: Timers time base
STATEMENT: >>>
The Timers of the Zephyr RTOS shall use the kernel's system clock to measure time.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a design decision. Just not clear why a timer implementation shall be restricted to the system clock. A justification for this descision would be helpful.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a design decision. Just not clear why a timer implementation shall be restricted to the system clock. A justification for this descision would be helpful.

Ok so removing the requirement here would be the best way? And the justification should be done in the design itself your should we do it on this level?

Add new Timers system requirements.
Remove user story from the system requirements.
Update description and titels of the existing requirements to
fit better to the guidelines.

Signed-off-by: Simon Hein <[email protected]>
Add new timers requirements on the software level
Remove the user stories from the existing requirements.
Remove obsolete requirements and rephrase existing ones.

Signed-off-by: Simon Hein <[email protected]>
Copy link

@tobiaskaestner tobiaskaestner left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just want to draw attention on the point about side-effects I made eaerlier again. I think it's good that these things bubble up now and I'd love to see more people take a look at this to make sure we are not overlooking an issue that has been dormant again.

COMPONENT: Timers
TITLE: Timer expire when thread synchronization is used
STATEMENT: >>>
When the thread synchronization mechanism is used, the thread shall be blocked until the timer expires.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me the API as we have it today in Zephyr is not ideal, e.g. the behaviour is somewhat ambiguous. Say, two threads synchronize on a given timer of which only one thread will be readied when the timer expires. But which of these two threads will that be? And is it deterministically always the same?
For me this boils down to poor semantics in the read status operation as it resets the status field as a side-effect.

That all said, probably not much we can do about it right now as we are trying to capture the RQTs as per the API as it is. Still, I wonder if for a functionally safe RTOS this needs changing first. Probably worth a discussion in a wider group.

COMPONENT: Timers
TITLE: Timer thread synchronization status reset
STATEMENT: >>>
When the thread synchronization mechanism is used, the status of the timer shall be reset.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's different views on semantics, I'd expect that syncing a thread on a timer should not affect the timer itself, since otherwise the operation will behave differently for the first and the following threads trying to sync at the same time. The current implementation in https://github.com/zephyrproject-rtos/zephyr/blob/911abc33e68b81c0490fa4b32a93d7d726640b73/kernel/timer.c#L295 resets the timer's status field after the timer expired and the first thread waiting for the timer runs again over this line. From the timer's perspective this happens at an arbitrary point in time as the (now running) thread might have spend an unspecified amount of time in the ready queue.

Not saying this is false per se, just that I am not really getting it yet, why things are the way they are.

Copy link

@nicpappler nicpappler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok for me when the open comments are resolved.

@simhein simhein self-assigned this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Requirements Requirements work
Projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

Timers Requirements
4 participants