작업 코드

thread.h

struct thread

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;
}

struct donation

typedef struct __donation__
{
	struct list_elem elem;
	int priority;
	struct thread *donor;
	struct lock *lock;
} donation;

thread.c

thread_set_priority

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();
}