Skip to content

Make ftime return wall clock#4

Open
StefanJum wants to merge 1 commit intounikraft:stagingfrom
StefanJum:fix-sem_timedwait
Open

Make ftime return wall clock#4
StefanJum wants to merge 1 commit intounikraft:stagingfrom
StefanJum:fix-sem_timedwait

Conversation

@StefanJum
Copy link
Copy Markdown
Member

@StefanJum StefanJum commented Feb 23, 2022

The problem was discussed here.

Return wall clock on calling ftime, since the
function is used in pte_relmillisecs to find
the time offset as milliseconds from the current
system time.

pte_relmillisecs returns timeout as milliseconds
from current system time, got by calling ftime here.
sem_timedwait calculates the time offset using
pte_relmillisecs here and then waits in a loop.

Using monotonic time results in a wrong offset
when using sem_timedwait that makes the abstime
argument be interpreted as a relative offset to
the monotonic clock start, not as an absolute value
since epoch.

Signed-off-by: Stefan Jumarea stefanjumarea02@gmail.com

Return wall clock on calling `ftime`, since the
function is used in `pte_relmillisecs` to find
the time offset as milliseconds from the current
system time.

`pte_relmillisecs` returns timeout as milliseconds
from current system time, got by calling `ftime`.
`sem_timedwait` calculates the time offset using
`pte_relmillisecs` and then waits in a loop.

Using monotonic time results in a wrong offset
when using `sem_timedwait` that makes the `abstime`
argument be interpreted as a relative offset to
the monotonic clock start, not as an absolute value
since epoch.

Signed-off-by: Stefan Jumarea <stefanjumarea02@gmail.com>
@razvand razvand requested a review from adinasm May 19, 2022 08:48
@razvand razvand self-assigned this May 19, 2022
Copy link
Copy Markdown

@adinasm adinasm left a comment

Choose a reason for hiding this comment

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

Looks good, seems like the bug is gone now.

Reviewed-by: Adina Smeu adina.smeu@gmail.com

@razvanvirtan razvanvirtan added this to the v0.11.0 (Janus) milestone Oct 6, 2022
@nderjung nderjung removed this from the v0.11.0 (Janus) milestone Feb 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 🧊 Icebox

Development

Successfully merging this pull request may close these issues.

5 participants