Skip to content
This repository has been archived by the owner on Dec 18, 2021. It is now read-only.

Proj1 discussion

Woojin Lee edited this page Sep 9, 2021 · 10 revisions

init.c 분석

  1. thread_init()
    "main" 스레드 생성
    init_thread()를 통해서 만드는데, 이 때는 THREAD_BLOCKED
    나중에 thread_init() 함수에서 다시 (THREAD_RUNNING)로 바꿔줌

  2. thread_start()
    "idle" 스레드 생성 thread_create()를 통해 생성 -> 쭉쭉 하다가 init_thread() 호출(THREAD_BLOCKED) -> thread_unblock(t) 할 때 THREAD_READY로 바꿈 여기서 idle(void *idle_started_ UNUSED) 함수 실행할 때, thread_block() 함수 실행됨 -> "main" 스레드가 THREAD_BLOCK으로 바뀜

thread_create()

init_thraed() 통해서 생성 -> THREAD_BLOCKED인 thread가 생성이 됨
이후 thread_unblock(t) 할 때 THREAD_READY로 들어감(ready_list에도 들어감)

thread_block()

얘는 RUNNING인 thread를 THREAD_BLOCKED로 바꿈
이때, schedule() 함수 실행

schedule()

ready_list에 있는 애를 가져옴(ready_list 비어있으면 idle 스레드, 아니면 ready_list의 제일 앞에 있는 애)
얘를 THREAD_RUNNING으로 바꿈

init.c timeline

https://cdn.discordapp.com/attachments/884468527564722177/884838544382779442/unknown.png
https://chayan-memorias.tistory.com/87?category=842655

priority donation

  1. normal
  2. multiple - stack
  3. nested - ??
    https://oslab.kaist.ac.kr/wp-content/uploads/esos_files/courseware/undergraduate/PINTOS/09_Priority_Inversion_Problem.pdf

donation data structure

기본적으로는 트리
우리는 list로 짜볼거에요 list 안에 list가 있는. (list는 donation)
child node 중에서 최댓값인 애가 subtree root node의 값으로 mimic
보면 생각나겠지:)

priority donation 큰그림

lock_acquire -> donate_prioroity
lock_release -> remove_with_lock -> refresh_priority

donate_priority -> donations list 만들고 priority donate
remove_with_lock(struct lock *lock) -> donations list에서 lock이 풀린 thread 삭제
refresh_priority -> lock의 holder에서 thread 삭제하고 priority 새로고침(thread_set_priority)