core.c를 제출하는 것이기 때문에 core.c 안에서의 변경은 무엇을 해도 상관
CFS, RT, DL, IDLE만 잘 출력해도
- schedule() 수정 (21.04, ref 표기 자유롭게)
sched.h- struct
core.c- edited line
//hw1
- kernel module programming
- can ref
sched.h
task_structschedule()// hw1 #define MAX_RECORDS 20 extern struct task_info { char task_name[64]; int pid; int priority; unsigned long long created_time; char scheduler_type[4]; } task_info; extern struct schedule_info { int cpu; struct task_info prev; struct task_info next; } schedule_info; // hw1
// hw1 struct schedule_info schedule_info_array[20]; int record_count = 0; extern struct schedule_info schedule_info_array[MAX_RECORDS]; extern int record_count; EXPORT_SYMBOL(schedule_info_array); EXPORT_SYMBOL(record_count); static void add_record(struct task_struct *prev, struct task_struct *next, int cpu) { if (record_count < MAX_RECORDS) { struct schedule_info *info = &schedule_info_array[record_count]; struct task_info prev_info = { .pid = prev->pid, .priority = prev->prio, .created_time = jiffies_to_msecs(jiffies - prev->start_time), }; struct task_info next_info = { .pid = next->pid, .priority = next->prio, .created_time = jiffies_to_msecs(jiffies - next->start_time), }; strncpy(prev_info.task_name, prev->comm, sizeof(prev_info.task_name)); strncpy(next_info.task_name, next->comm, sizeof(next_info.task_name)); switch (prev->policy) { case SCHED_NORMAL: strncpy(prev_info.scheduler_type, "CFS", sizeof(prev_info.scheduler_type)); break; case SCHED_FIFO: strncpy(prev_info.scheduler_type, "RT", sizeof(prev_info.scheduler_type)); break; case SCHED_DEADLINE: strncpy(prev_info.scheduler_type, "DL", sizeof(prev_info.scheduler_type)); break; case SCHED_IDLE: strncpy(prev_info.scheduler_type, "IDLE", sizeof(prev_info.scheduler_type)); break; } switch (next->policy) { case SCHED_NORMAL: strncpy(next_info.scheduler_type, "CFS", sizeof(next_info.scheduler_type)); break; case SCHED_FIFO: strncpy(next_info.scheduler_type, "RT", sizeof(next_info.scheduler_type)); break; case SCHED_DEADLINE: strncpy(next_info.scheduler_type, "DL", sizeof(next_info.scheduler_type)); break; case SCHED_IDLE: strncpy(next_info.scheduler_type, "IDLE", sizeof(next_info.scheduler_type)); break; } info->cpu = cpu; info->prev = prev_info; info->next = next_info; record_count++; } else { memmove(schedule_info_array, schedule_info_array + 1, sizeof(schedule_info_array) - sizeof(struct schedule_info)); record_count--; add_record(prev, next, cpu); } } // hw1 // hw1 add_record(prev, next, cpu); // hw1
Seonglae Cho