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

Support Spinlock #32

Merged
merged 2 commits into from
Jul 25, 2024
Merged

Support Spinlock #32

merged 2 commits into from
Jul 25, 2024

Conversation

0Bitbiscuits
Copy link
Contributor

  1. 提供原子操作库:stdatomic.h
  2. 使用原子操作函数实现spinlock为mlibc提供可重入支持做准备

Copy link
Collaborator

@BernardXiong BernardXiong left a comment

Choose a reason for hiding this comment

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

代码风格请检查下。

另外,建议多考虑到后续arch的问题,也包括这其中可能也用到了gcc内置的一些code?如果更换了编译器会怎么办,如果是llvm呢?

* @brief atomic type definition
*/
typedef _Atomic(bool) atomic_bool;
typedef _Atomic(char) atomic_char;
Copy link
Collaborator

Choose a reason for hiding this comment

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

这边对齐应该存在不一致

Copy link
Contributor Author

@0Bitbiscuits 0Bitbiscuits Jul 24, 2024

Choose a reason for hiding this comment

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

明白!

@0Bitbiscuits
Copy link
Contributor Author

修改:

  1. 给stdatomic模块添加相关宏便于后续扩展,目前只支持GNUC的原子操作

TODO:

  1. 实现libc对mutex和sem的支持
  2. 不依赖编译器,在libc中提供硬件原子操作

@BernardXiong BernardXiong merged commit 1feaf76 into plctlab:main Jul 25, 2024
@0Bitbiscuits 0Bitbiscuits deleted the spinlock branch July 28, 2024 08:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants