Skip to content

WaitChannel design #241

Closed
Closed
@efenniht

Description

@efenniht

WaitChannel 에 대해서 고민해봤는데, 이런 형태의 디자인이 과연 올바른 지 궁금합니다. @jeehoonkang

  • 원래 xv6 는 애초에 wait channel 이라는 type 이 없고 서로 다른 변수에 대한 주소를 wait channel identifier로 사용합니다. Make wait channel non-zero-sized #236 에 의해 WaitChannel 을 들고 있는 타입은 크기가 커집니다. 그렇다고 WaitChannel<T> 같은 타입은 더 이상한 것 같습니다.
  • WaitChannel 은 주소가 wait 대상의 identifier 가 되므로 move 되면 스레드를 깨워도 일어나지 않거나 이상한 스레드가 깨는 등 의도되지 않은 일이 일어날 수 있습니다. 따라서 올바른 API는 sleep(self: Pin<&mut Self>, ...) 이 되어야 합니다. 다만 이것은 safety invariant 는 아니므로 주석만 쓰고 넘길 수도 있습니다.
  • Redox 의 구현은 해당 채널을 대기하고 있는 스레드를 queue 에 넣어서 WaitChannel 의 멤버로 들고 있습니다. 이러면 channel 이 move 되어도 문제가 없습니다.

어떻게 수정하는 것이 옳을까요?

  1. 현상 유지
  2. Pin 넣고 타입 대공사
  3. Redox 처럼 수정하기

Originally posted by @efenniht in #236 (comment)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions