본문 바로가기
OldStory/WORKS

커널쓰레드의 우선 순위 변경

by Alnilam 2010. 10. 27.

리눅스 드라이버의 커널 쓰레드를 사용하는 경우 쓰레드의 우선순위(priority)를 변경하고 싶은 경우 set_user_nice 함수를 사용하여 변경 할 수 있다.

일반적으로 우선순위를 설정하지 않은 커널 쓰레드의 우선순위의 값은 -5이며 set_user_nice함수에서 설정할 수 있는 값의 범위는 -20에서 19 이다.
-20 이 우선 순위가 가장 높고 19가 가장 낮다.

사용 방법은 커널 쓰레드 함수 내에서 다음과 같이 호출 한다.
set_user_nice(current, -20);

각 쓰레드의 우선 순위 확인 방법은 콘설에서 "ps -elf" 명령을 사용하여 확인 할 수 있으며 NI 값이 우선순위를 나타 낸다.

root@at91sam9xeek:~# ps -elf
F S UID PID PPID C PRI NI ADDR SZ WCHAN STIME TTY TIME CMD
4 S root 1 0 0 80 0 - 374 poll_s 07:23 ? 00:00:02 init [5]
1 S root 2 0 0 75 -5 - 0 kthrea 07:23 ? 00:00:00 [kthreadd]
1 S root 3 2 0 75 -5 - 0 ksofti 07:23 ? 00:00:00 [ksoftirqd/0]
1 S root 4 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [events/0]
1 S root 5 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [khelper]
1 S root 8 2 0 75 -5 - 0 async_ 07:23 ? 00:00:00 [async/mgr]
1 S root 81 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [kblockd/0]
1 S root 89 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [kmmcd]
1 S root 117 2 0 80 0 - 0 pdflus 07:23 ? 00:00:00 [pdflush]
1 S root 118 2 0 80 0 - 0 pdflus 07:23 ? 00:00:02 [pdflush]
1 S root 119 2 0 75 -5 - 0 kswapd 07:23 ? 00:00:00 [kswapd0]
1 S root 120 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [aio/0]
1 S root 121 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [nfsiod]
1 S root 122 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [crypto/0]
1 S root 239 2 0 75 -5 - 0 mtd_bl 07:23 ? 00:00:00 [mtdblockd]
1 S root 277 2 0 75 -5 - 0 worker 07:23 ? 00:00:00 [rpciod/0]
5 S root 304 1 0 76 -4 - 426 poll_s 07:23 ? 00:00:00 /sbin/udevd -d
1 S root 565 2 0 90 10 - 0 jffs2_ 07:23 ? 00:00:09 [jffs2_gcd_mtd]
5 S daemon 662 1 0 80 0 - 371 poll_s 07:24 ? 00:00:00 /sbin/portmap
1 S root 694 1 0 80 0 - 506 poll_s 07:24 ? 00:00:00 /usr/sbin/dropb
5 S 45 701 1 0 80 0 - 501 poll_s 07:24 ? 00:00:00 /usr/bin/dbus-d
0 S root 704 1 0 80 0 - 664 skb_re 07:24 ? 00:00:00 /sbin/syslogd -
4 S root 706 1 0 80 0 - 648 syslog 07:24 ? 00:00:01 /sbin/klogd -n
5 S nobody 711 1 0 80 0 - 510 poll_s 07:24 ? 00:00:00 /usr/sbin/thttp
5 S avahi 719 1 0 80 0 - 634 poll_s 07:24 ? 00:00:00 avahi-daemon: r
4 S root 730 1 0 80 0 - 692 wait 07:24 ttyS0 00:00:00 -sh
1 S root 1285 694 0 80 0 - 549 poll_s 09:16 ? 00:00:03 /usr/sbin/dropb
4 S root 1286 1285 0 80 0 - 692 wait 09:16 pts/0 00:00:00 -sh
0 S root 1342 730 0 80 0 - 648 wait 09:36 ttyS0 00:00:00 /bin/sh ./down.
1 S root 1349 2 0 75 -20 - 0 dmb_th 09:36 ? 00:00:00 [dmb_thread]
0 S root 1353 1342 0 80 0 - 6570 n_tty_ 09:36 ttyS0 00:00:00 ./fccon
4 R root 1358 1286 0 80 0 - 556 - 09:40 pts/0 00:00:00 ps -elf
root@at91sam9xeek:~#

'OldStory > WORKS' 카테고리의 다른 글

ffmpeg - TDMB  (0) 2011.02.21
SMDKV210  (0) 2010.11.24
MS .NET Framework 3.5 설치 문제  (0) 2010.10.22
ctrl-c handler  (0) 2010.10.21
Address Already in Use 에러  (0) 2010.10.21