우선순위 역전이 무엇인가?

우선순위 기부가 무엇인가?

연쇄 기부(chain donate)는 무엇인가?


중첩 기부는 무엇인가?


중첩 기부받은 쓰레드 B가 다른 쓰레드 M의 락을 기다리게 되어서 기부하게 될 때 B의 기부 리스트에는 무엇이 들어가야 하는가?
struct thread
{
/* Owned by thread.c. */
tid_t tid; /* Thread identifier. */
enum thread_status status; /* Thread state. */
char name[16]; /* Name (for debugging purposes). */
int priority; /* 기부받은 우선순위 */
int original_priority; /* 원래의 우선순위 */
/* Shared between thread.c and synch.c. */
struct list_elem elem; /* List element. */
struct list donations; /* 자신한테 기부해준 리스트 */
struct lock *pending_lock;
}
typedef struct __donation__
{
struct list_elem elem;
int priority;
struct thread *donor;
struct lock *lock;
} donation;
void thread_set_priority(int new_priority)
{
struct thread *cur = thread_current();
thread_current()->original_priority = new_priority;
if (list_empty(&cur->donations))
{
cur->priority = new_priority;
}
else
{
int first_priority = list_entry(list_front(&cur->donations), donation, elem)->priority;
if (first_priority > new_priority)
cur->priority = first_priority;
else
cur->priority = new_priority;
}
compare_cur_next_priority();
}