-
Notifications
You must be signed in to change notification settings - Fork 7.4k
kernel + posix: add k_spin_trylock(), pthread_spin_lock(), etc #59911
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
Conversation
a89bf38
to
a4ee073
Compare
a4ee073
to
315ed52
Compare
315ed52
to
9302399
Compare
2b8bb59
to
a17cf28
Compare
b842bb2
to
52234f1
Compare
lib/posix/pthread_spinlock.c
Outdated
return l - posix_spinlock_pool; | ||
#else | ||
/* Workaround for struct k_spinlock being zero bytes */ | ||
__ASSERT_NO_MSG(sizeof(struct k_spinlock)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why runtime assertion? Let's use BUILD_ASSERT
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@evgeniy-paltsev - Fixed!
52234f1
to
621a587
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re-stamp
4aaffbc
4d15ba6
to
4aaffbc
Compare
4aaffbc
to
f2c40ad
Compare
@andyross, @peter-mitsis, @ycsin - please re-stamp. I added a change to That will let us avoid the need for merge superpowers constantly for |
The `USE_NEGATIVE_ERRNO` rule consistently generates false positives when working with certain areas of POSIX. It makes sense to disable this check for the POSIX API rather than requiring merge superpowers constantly. That way, we can merge as per usual after sufficient approvals rather than waiting for someone with merge superpowers to override / manually merge. Signed-off-by: Christopher Friedt <[email protected]>
f2c40ad
to
9d09b4c
Compare
There is some opportunity to increase compiler optimization by providing the public pthread methods as inline wrappers that take a The check that |
There is always room for optimization but that can be done on an as-needed basis at a later date with evidence / measurements. Additionally, having something that works and meets the spec is more important, and I would avoid inlining anything that isn't specifically mentioned that it could possibly be an inline function or macro.
Technically, that check isn't even required by the standard and it represents undefined behaviour. I was thinking about making it an
Yep - keeping |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Refresh +1
The same also for both checks for use of an uninitialized spinlock, undefined behavior in POSIX, but certainly a nice debugging aid. The second check makes all spinlocks contend for access to the single spinlock protecting |
This change adds a new spinlock API,
k_spin_trylock()
, in order to implementpthread_spin_lock()
and friends. Part of the POSIX Roadmap for LTSv3.Fixes #59910