Skip to content

운영체제 13회#68

Merged
sigridjineth merged 3 commits intomainfrom
han
Nov 20, 2021
Merged

운영체제 13회#68
sigridjineth merged 3 commits intomainfrom
han

Conversation

@102092
Copy link
Copy Markdown
Contributor

@102092 102092 commented Nov 3, 2021

issue : #65 , #67
due date : 2021/11/09

@102092 102092 requested a review from sigridjineth November 3, 2021 11:18
@102092 102092 self-assigned this Nov 3, 2021
sigridjineth
sigridjineth previously approved these changes Nov 13, 2021
Copy link
Copy Markdown
Contributor

@sigridjineth sigridjineth left a comment

Choose a reason for hiding this comment

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

수고 많으셨습니다! 정리가 잘 되어 있네요.

Comment thread operating-system/mutex-semaphore/han/README.md Outdated
- 왜?
- 해당 공유자원을 점유하고 있는 스레드 뿐만 아니라, 물어보는 다른 스레드의 요청까지 처리해줘야 하므로..
- 그럼 어떤 상황에 위 방식을 사용할까?
- 대기큐를 사용하는 방식보다, 공유자원에게 물어보는 시간이 짦다면.. 굳이 대기큐를 사용하지 않아도 될듯. (컨텍스트 스위칭 시간이 짦으면..)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

이런 경우가 얼마나 있을까요? 사례를 하나 들어주실 수 있나요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

특정한 사례...보다는, 위 경우는 개발자가 상황에 맞게 사용해야한다는 뜻 같아요.

제 생각엔 공유자원을 잡고 진행하는 작업이 있는데 이 작업이 자원소모가 크지 않거나, 걸리는 시간이 짦다면
굳이 대기큐라는 방법보다는, 매번 프로세스가 물어보도록 하는게 더 효율적일 수도 있다 라는 의미라고 이해했어요.

> 작동 방식

1. Lock
- 공유 자원에는 `Boolean Lock` 변수가 있음
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

해당 프로퍼티를 포함한 Mutex Object를 반환하는 것 같아요!



# Semaphore
- 다수의 프로세스, 스레드가 여러 개의 공유자원에 대한 접근을 제한하는 방법
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

N:N 관계라는 것이 핵심인 것 같아요!


- OS에 핵심 부분인, 컴퓨터 프로그램을 의미.
- 시스템의 모든 것을 제어할 수 있도록 도와주는 부분.
- 항상 메모리에 상주하고 있으며, 하드웨어와 소프트웨어의 상호작용을 할 수 있도록 도와주는 핵심적인 인터페이스를 의미.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

부트로더에 상주한다고 하네요. 부트로더가 무엇인가요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

부트로더에 상주한다고 하네요.

커널이 부트로더에 상주한다는 말씀이신가요?
우선 부트로더는 커널이 올바르게 시동되기 위해 필요한 작업을 진행하는 프로그램으로 이해했습니다.

- 즉 여러개의 스레드는 하나의 프로세스 (Many to One) 관리한다고 보면 됨.
- Context swiching 이 커널 레벨 스레드 보다 적게 일어남.
- 커널에 진입하지 않아도, 라이브러리 지원을 통해 스레드를 사용할 수 있게 함.
- Ex) Jvm with thread
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

컨텍스트 스위칭도 JVM 레벨에서 하는 거지, 커널 레벨에서는 단일 프로세스에 메모리를 주고 있다고 생각하나 보네요.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

컨텍스트 스위칭도 JVM 레벨에서 하는 거지, 커널 레벨에서는 단일 프로세스에 메모리를 주고 있다고 생각하나 보네요.

말씀하신게 어떤 내용인지 잘 이해 못했어요.
좀더 설명해주실 수 있나요?

- 어떤 프로세스에 여러 개의 스레드가 있다고 가정할 때,
- 하나의 스레드가 커널을 호출 한다면 (System call)
- 해당 프로세스 내, 모든 스레드가 중단될 것 (Blocking System)
- 그래서 user level thread를 사용하기 위해서는 non-blocking system call이 필요함. (커널을 호출하더라도, blocking 되지 않도록..?)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

예를 들어서 I/O 작업을 해야 할 때, Kernel-Level Thread 별로 User-Level Thread가 하나씩 배정되는데요. non-blocking system call로 I/O가 non-blocking하게 하려면 어떻게 구현해야 할까요?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

User Level Thread가 시스템 콜 할 때, 커널 점유할 때, 해당 스레드가 Blocking 되지 않도록 해야되는 걸로 이해했습니다.

non-blocking system call로 I/O가 non-blocking하게 하려면 어떻게 구현?

이 부분에 대해서는 잘 모르겠어요.
non-blocking system call 이라는 건, 이미 I/O를 할 때, 그러니까 어떤 유저 레벨 스레드가 커널을 점유하는 걸 non-blocking 하도록 한다는 의미로 이해했는데 맞을까요?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants