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

Use SpinLock instead of RawSpinLock #20

Closed
efenniht opened this issue Aug 12, 2019 · 0 comments · Fixed by #39
Closed

Use SpinLock instead of RawSpinLock #20

efenniht opened this issue Aug 12, 2019 · 0 comments · Fixed by #39

Comments

@efenniht
Copy link
Collaborator

efenniht commented Aug 12, 2019

RawSpinLock 대신 SpinLock을 쓰도록 합니다. 이러면 좋은 이유는:

  • 락이 잠그는 대상이 코드가 아니라 데이터가 됩니다. 정적으로 이해하기 더 쉬워져요.
  • 그러므로 락이 필요한 데이터와 락이 필요없는 데이터를 분리하여 효율이 높아집니다.
  • LockGuard를 이용해 락을 풀지 않고 리턴하는 경우를 막을 수 있습니다.

이 문제를 해결하는 방법의 순서를 생각해봅시다.

  1. 먼저 C 코드에서 sl_lock을 통해서 RawSpinLock을 사용하는 곳이 있는 지 확인합니다. 이런 락은 안타깝게도 바꿀 수가 없습니다 C 코드를 먼저 수정해야 합니다.
  2. 이제 바꿀 락에 대하여, 이 락이 무엇을 보호하는 지 조사해야 합니다. Hafnium System Review 문서와 대조해 봅니다.
  3. 그런 다음 이 자료들을 묶어서 XXXState 따위로 만들고 이것에 대한 SpinLock을 사용합니다.
  4. 그리고 sl_lock을 호출하던 Rust 코드를 리팩토링합니다.
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 a pull request may close this issue.

1 participant