#define TASK의 모든 상태 비트 마스크
TASK_RUNNING
TASK_INTERRUPTIBLE
TASK_UNINTERRUPTIBLE
TASK_STOPPED
TASK_TRACED
TASK_EXIT_ZOMBIE
TASK_EXIT_DEAD
TASK_NONINTERACTIVE
int lock_depth; /* BKL lock depth */
/*
* We keep the big kernel semaphore locked,
* but we clear ->lock_depth so that schedule() doesnt
* auto-release the semaphore:
* 실행 큐를 보호하기 위한 락은 순서대로 잠금을 해야한다
*/
#if defined(CONFIG_SMP) && defined(__ARCH_WANT_UNLOCKED_CTXSW)
int oncpu;
#endif
/*
* SMP 다중 프로세서 동시성에 대한 안전
* 다중 프로세서 일때 필요한 옵션
*/
int prio, static_prio;
/*
* nice 우선순위 -20 ~ 19 (default 0)
* static_prio 정적 우선순위
* prio 동적우선순위
* effective_prio(task_t *p) 동적우선순위 계산
* prio = p->static_prio - bonus;
*/
struct list_head run_list;
/*
* list.h => list_head { *pre,*next }
* 커널이 제공하는 리스트 자료구조 사용하여
* run_list 를 만듬
* 실행가능한 task ???
* 그럼 이게 runqueue ???
* 이건 task의 list run 이란 의미는 current와 비슷한의미
* list_entry(ptr,type,member)
*/
prio_array_t *array;
/*
* struct prio_array {
* unsigned int nr_active;
* ready_task, wait_task이냐, 우선순위 배열은 2개가 존재한다.
*
* unsigned long bitmap[BITMAP_SIZE];
* 현재실행중인 모든 task의 우선 순위 비트 맵
*
* struct list_head queue[MAX_PRIO]; }
* 각각의 우선순위들은 하나의 큐를 가지고있다
* (해쉬와 같은 포인터 배열을 나타낸다)
*
* list_entry(array->queue[sched_find_bit(array->bitmap)])
* 를 이용하면 한번에 우선순위가 가장높은 task를 가져올수있다
* O(1)
*/
//===== 런 큐는 우리가 생각하는 하나의 리스트가 아니라
//실행가능한 task중 우선순위 큐의 제일 앞의 task들을 말한다.
//struct runqueue *rq; 는 여기서 선택된 task의 포인터
//이다 : 실행중인 task
//(cpu를 점유하고 있는 task(current)를 가르킨다.)
unsigned short ioprio;
/* 실시간 우선순위를 말하는듯???
* 0~99 까지 (정적)
*/
//=== 동적인 우선순위 부여를 위해 time_slice 계산
unsigned long sleep_avg;
/*
* 휴면시간 실행중일때마다 감소
* 0 ~ MAX_SLEEP_AVG (default 10ms)
*/
unsigned long long timestamp, last_ran;
/* cpu tick를 기록(전원이 들어오는순간 계속 증가하는 시간)
* 스케쥴링 들어올때 cpu tick,timestamp
* 스케쥴링 나갈때 cpu tick, last_ran
* task를 스케쥴링 할때 timestamp 와
* task에 기록되어있는 마지막 스케쥴링되었을때의 last_ran
* timestamp - last_ran = 실행시간
*/
unsigned long long sched_time; /* sched_clock time spent running */
/*
* 실행시간을 기록한다.
*/
int activated;
/*
* 이 task의 활성/비활성 상태를 나타낸다
* 활성 상태가되면 실행가능한 대기상태로 간다.
* 위의 state는 runable,unrunable,zombi를 나타난다
*/
unsigned long policy;
/*
* 우선순위 정책으로
*
* SCHED_FIFO(실시간),실시간우선순위
* - 단순한 선입출 알고리즘, time_slice사용하지않음
*
* SCHED_RR(실시간,정해진 시간),실시간 우선순위
* - FIFO와 같지만 time_slice를 사용
*
* SCHED_NORMAL(비 실시간),nice
* -
*
* SCHED_BATCH(비 실시간),nice
* -
*
* 나누어지고 실제 코드에서 switch case로 구현
*/
cpumask_t cpus_allowed;
/*
* SMP 다중 cpu에 대한 task의 소속
* CPU_MASK_NONE 이tkask 는 모든 프로세서에서 실행 가능하다.
* 변경하여 특정 프로세서그룹에서만 실행할수 있게 할수도있다.
* task의 상성,
*/
unsigned int time_slice, first_time_slice;
/*
* 동적 time_slice 정적 first_time_slice
* 우선순위에따른 비례확장한 시간
* task_timeslice() 함수사용
*/
#ifdef CONFIG_SCHEDSTATS
struct sched_info sched_info;
#endif
/*
* schedule()
* task switch, context switch
*
* /
/**
* list_entry - get the struct for this entry
* @ptr: the &struct list_head pointer.
* @type: the type of the struct this is embedded in.
* @member: the name of the list_struct within the struct.
*/
#define list_entry(ptr, type, member) \
container_of(ptr, type, member)
/*
* time_slice 0이되면 활성/비활성 배열에 삽입/삭제
if (!--p->time_slice) {
dequeue_task(p, rq->active);
set_tsk_need_resched(p);
p->prio = effective_prio(p);
p->time_slice = task_timeslice(p);
p->first_time_slice = 0;
if (!rq->expired_timestamp)
rq->expired_timestamp = jiffies;
if (!TASK_INTERACTIVE(p) || EXPIRED_STARVING(rq)) {
enqueue_task(p, rq->expired);
if (p->static_prio < rq->best_expired_prio)
rq->best_expired_prio = p->static_prio;
} else
enqueue_task(p, rq->active);
} else {
if (TASK_INTERACTIVE(p) && !((task_timeslice(p) -
p->time_slice) % TIMESLICE_GRANULARITY(p)) &&
(p->time_slice >= TIMESLICE_GRANULARITY(p)) &&
(p->array == rq->active)) {
requeue_task(p, rq->active);
set_tsk_need_resched(p);
}
}
*/
/* wait_queue
* struct __wait_queue {
* unsigned int flags;
* void *private;
* wait_queue_func_t func;
* struct list_head task_list;
* }
*/
[출처] 스케쥴링에 관한 task_struct 정보|작성자 아까멘치
이올린에 북마크하기
이올린에 추천하기

