Skip to content

Conversation

nashif
Copy link
Member

@nashif nashif commented Mar 25, 2024

  • high-level: refine mutex requirement
  • mutex: add requirements for a mutex

Mutex functional requirements.

Signed-off-by: Anas Nashif <[email protected]>
STATEMENT: >>>
While a thread no longer requires exclusive access to a shared resource, the
Zephyr RTOS shall provide a mechanism to unlock a mutex.
<<<

Choose a reason for hiding this comment

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

Remove the While clause. The mechanism needs to always be provided.

Choose a reason for hiding this comment

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

"The Zephyr RTOS shall provide a mechanism for the owning thread to unlock a mutex."

Copy link
Contributor

Choose a reason for hiding this comment

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

I second with Tims suggestion for the RQT.

STATEMENT: >>>
When a mutex is successfully unlocked by a thread, the Zephyr RTOS shall ensure
that the mutex becomes available for locking by other threads.
<<<

Choose a reason for hiding this comment

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

How do you verify "ensure"? Can the verification be automated?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes, we test for this already.

Choose a reason for hiding this comment

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

Restate without superfluous infinitives per INCOSE GtWR R10.

Copy link

@Timotheous Timotheous Apr 2, 2024

Choose a reason for hiding this comment

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

I think this requirement is intended to cover the atomic mutex operation of unlocking and then locking for the next waiting thread.

If so, I suggest:
"When a mutex is unlocked and another thread waiting to lock that mutex, the unlock and lock operations shall be atomic"

TITLE: Timed locking of a Mutex
STATEMENT: >>>
Mutexes shall support timed locking, where threads can specify a timeout period for waiting on the mutex.
<<<

Choose a reason for hiding this comment

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

You just changed abstraction levels. "the Zephyr RTOS shall" is a different level than "Mutexes shall".

Rephrase to remove "where". Reserve "where" for preconditions.

Choose a reason for hiding this comment

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

Seems like the Semaphore requirements covering timeouts should be duplicated for mutexes.

Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency of language this RQT should also start with "The Zephyr RTOS shall support ..." the more consistent RQTs are written the easier they become to parse (by humans and non-humans alike)

TITLE: Priority Inheritance
STATEMENT: >>>
When using mutexes for resource synchronization, the Zephyr RTOS shall implement priority inheritance protocols to prevent priority inversion scenarios.
<<<

Choose a reason for hiding this comment

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

Remove the While clause. The mechanism needs to always be provided.

"shall implement" is not an observable behavior. Are you intentionally trying to constrain the implementation? If so, how do you verify this? Can verification be automated?

Copy link
Member Author

Choose a reason for hiding this comment

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

please provide a suggestion on the wording. I do not see any other way this can
be expressed. You keep asking about automation of verification, not sure what
you mean by now, this is something that can be tested, yes, why are we talking
about automation? why is this relevant?

Choose a reason for hiding this comment

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

Mutexes are only used for resource synchronization, so remove the conditional.

"to prevent priority inversion scenarios" is justification. Remove it (INCOSE GtWR R20).

Priority inheritance is implied by mutex in an RTOS. I think this is a better description for the highest abstraction layers: "The Zephyr shall expose mutex services."

Choose a reason for hiding this comment

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

{sigh}

Automated verification helps fulfill a critical User Need: to be able to verify the OSS software with the User-provided qualified toolchain in a timely manner. There are 4 identified methods for verification: Test, Demonstration, Inspection, Analysis. Doing full verification manually takes FAR too long, so product integrators need automated verification suites to come with the OSS. The most natural verification type to automate is Test.

AFAICT the biggest enabler to deploying and updating secure systems is the rapid integration, revalidation, and deployment of security fixes. Product manufacturers soon will need to publicly commit to a specific response time to security issues (e.g., 30d, 60d, 90d). Component providers (e.g., Nordic, Zephyr Project) that commit to rolling out security fixes faster than the product manufacturer commitment remain as viable suppliers. Those that do not lose out on the design win.

Copy link
Member Author

Choose a reason for hiding this comment

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

Requirements need to be testable, fully agree with that and there is no argument. Automation is key and we need to get to almost 100% automation, sure thing.
Asking if the some requirement can be tested or verified is fine, however asking if "verification can be automated" is off-topic and I did not know what you mean because of that.

AFAICT the biggest enabler to deploying and updating secure systems is the rapid integration, revalidation, and deployment of security fixes. Product manufacturers soon will need to publicly commit to a specific response time to security issues (e.g., 30d, 60d, 90d). Component providers (e.g., Nordic, Zephyr Project) that commit to rolling out security fixes faster than the product manufacturer commitment remain as viable suppliers. Those that do not lose out on the design win.

This is going off-topic.

Copy link

@Timotheous Timotheous Apr 2, 2024

Choose a reason for hiding this comment

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

"Mutexes shall implement priority inheritance protocols."

Implement does not tell me how priority inheritance behaves. But the next two requirements address priority inheritance specifically.

TITLE: Priority Inheritance - priority elevation
STATEMENT: >>>
When a higher-priority thread begins waiting on the mutex, the Zephyr RTOS shall temporarily elevate the priority of the owning thread.
<<<

Choose a reason for hiding this comment

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

How is this distinct from the "Priority Inheritance" requirement above? If these are at different levels of detail then they need to reference each other.

Use "While" instead of "When". This condition is a state not an event.

Choose a reason for hiding this comment

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

"While a higher-priority thread is waiting on a mutex, the Zephyr RTOS shall elevate the priority of the owning thread."

TITLE: Mutex Ownership
STATEMENT: >>>
Mutexes shall track the owning thread when locked to ensure exclusive access to the associated resource.
<<<

Choose a reason for hiding this comment

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

Remove "to ensure ...". It is justification not observable behavior or condition.

Choose a reason for hiding this comment

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

"Mutexes shall track the owning thread when locked"

I think I made this a second part to ZEP-MUTEX-4 Exclusive Locking of a Mutex

TITLE: Mutex Ownership - Unlock
STATEMENT: >>>
The Zephyr RTOS shall allow only the owning thread to unlock the mutex.
<<<

Choose a reason for hiding this comment

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

Avoid using the word "only" in requirements. It is usually(?) very hard or impossible to verify.

In many cI think this is better phrased as:

While the mutex is not in a recursive lock,
When the thread owning a mutex requests to unlock it,
the ... shall ...

Choose a reason for hiding this comment

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

I think this is covered by my suggested wording for ZEP-MUTEX-5 Unlocking of a Mutex:
"The Zephyr RTOS shall provide a mechanism for the owning thread to unlock a mutex."

TITLE: Priority Ceiling
STATEMENT: >>>
The Zephyr RTOS shall implement priority ceiling protocols to limit the extent of priority elevation during priority inheritance.
<<<

Choose a reason for hiding this comment

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

Remove the justification phrase "to limit ...".

"shall implement" is not an observable behavior. Are you intentionally trying to constrain the implementation? If so, how do you verify this? Can verification be automated?

STATEMENT: >>>
While a thread no longer requires exclusive access to a shared resource, the
Zephyr RTOS shall provide a mechanism to unlock a mutex.
<<<
Copy link
Contributor

Choose a reason for hiding this comment

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

I second with Tims suggestion for the RQT.

TITLE: Timed locking of a Mutex
STATEMENT: >>>
Mutexes shall support timed locking, where threads can specify a timeout period for waiting on the mutex.
<<<
Copy link
Contributor

Choose a reason for hiding this comment

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

For consistency of language this RQT should also start with "The Zephyr RTOS shall support ..." the more consistent RQTs are written the easier they become to parse (by humans and non-humans alike)

@simhein simhein added the Requirements Requirements work label May 13, 2024
@Timotheous
Copy link

I would hate to lose the work that has been done on this PR.
The nature of the "discussion" has made it hard for the owner to implement any changes.

Even without changes, it is better than the near empty file it will replace.

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.

5 participants