리눅스 커널의 time slice는 몇초인지요?

maja의 이미지

리눅스 커널의 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정도 나오는듯도 하네요.

익명 사용자의 이미지

아... 저도 질문 하나 추가하고 싶습니다^^;;

타임 슬라이스가 뭐죠?

프로세서의 타이머를 이용해 스케쥴링하는 주기를 말하는 것 같긴한데....

ㅎㅎ... 너무 기초적인 질문인가요;;

maja의 이미지

저도 잘 모르지만..^^
한개의 프로세스에 할당된 실행시간(?)정도 될겁니다.
time slice가 지나면 다시한번 스케줄링이 되어지고요...

tristansong의 이미지

여기에 자세한 설명이 있네요 :D
http://www.oreilly.com/catalog/linuxkernel/chapter/ch10.html

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.