리눅스 커널의 time slice는 몇초인지요?
리눅스 커널의 time slice는 몇초인지요?
DEF_COUNTER값을 보고 100ms로 알고있었는데....
schedule()을 보니 50ms인것같아서요.
(We want the time-slice to be around 50ms )
커널버전은 2.4대입니다.
핵심코드만 나열해보면...다음과 같습니다.
616 if (unlikely(!c)) {
617 struct task_struct *p;
618
619 spin_unlock_irq(&runqueue_lock);
620 read_lock(&tasklist_lock);
621 for_each_task(p)
622 p->counter = (p->counter >> 1) + NICE_TO_TICKS(p->nice);
623 read_unlock(&tasklist_lock);
624 spin_lock_irq(&runqueue_lock);
625 goto repeat_schedule;
626 }
48 /*
49 * Scheduling quanta.
50 *
51 * NOTE! The unix "nice" value influences how long a process
52 * gets. The nice value ranges from -20 to +19, where a -20
53 * is a "high-priority" task, and a "+10" is a low-priority
54 * task.
55 *
56 * We want the time-slice to be around 50ms or so, so this
57 * calculation depends on the value of HZ.
58 */
59 #if HZ < 200
60 #define TICK_SCALE(x) ((x) >> 2) //#####
61 #elif HZ < 400
62 #define TICK_SCALE(x) ((x) >> 1)
63 #elif HZ < 800
64 #define TICK_SCALE(x) (x)
65 #elif HZ < 1600
66 #define TICK_SCALE(x) ((x) << 1)
67 #else
68 #define TICK_SCALE(x) ((x) << 2)
69 #endif
70
71 #define NICE_TO_TICKS(nice) (TICK_SCALE(20-(nice))+1)
457 #define DEF_COUNTER (10*HZ/100) /* 100 ms time slice */
458 #define MAX_COUNTER (20*HZ/100)
459 #define DEF_NICE (0)
---------------------------------------------------------------------
피에쓰.
아니면.. init process 는 time slice가 100ms이고
다른건 50ms일까요.
처음 init이 다른거 만들때 반으로 쪼개서 주니까 50ms가 될테고
다음부터는 nice값이 0니까 NICE_TO_TICKS 계산하면 대략 50ms정도 나오는듯도 하네요.
...
아... 저도 질문 하나 추가하고 싶습니다^^;;
타임 슬라이스가 뭐죠?
프로세서의 타이머를 이용해 스케쥴링하는 주기를 말하는 것 같긴한데....
ㅎㅎ... 너무 기초적인 질문인가요;;
저도 잘 모르지만..^^ 한개의 프로세스에 할당된 실행시간(?)정도
저도 잘 모르지만..^^
한개의 프로세스에 할당된 실행시간(?)정도 될겁니다.
time slice가 지나면 다시한번 스케줄링이 되어지고요...
도움이 좀 되시길..
여기에 자세한 설명이 있네요 :D
http://www.oreilly.com/catalog/linuxkernel/chapter/ch10.html
댓글 달기