커널 분석(인터럽트)
본 자료는 4페이지 의 미리보기를 제공합니다. 이미지를 클릭하여 주세요.
닫기
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
해당 자료는 4페이지 까지만 미리보기를 제공합니다.
4페이지 이후부터 다운로드 후 확인할 수 있습니다.

목차

IRG

Multi process

Handler structure

irg_do() 함수분석

Handle_irq_event() 함수분석

Bottom half

do_softirq() 함수분석

본문내용

를 확인하여 do_softirq( )을 수행하게 된다.
- do_softirq( ) 을 call 되는 3가지 경우가 있다.
top half 가 일을 마치고 돌아갈 때 do_irq( )에서 irq_exit()을 call하는 부분이 있다. irq_exit() - > do_softirq( ) 을 call 하게 된다.
cpu 마다 kernel thread 가 있는데 ksoft_irqd_cpu 가 낮은 우선 순위라서 높은 우선순위가 있는 것이 다 실행 한 후 차례가 왔을때 ksoft_irqd_cpu가 수행될때 do_softirq( ) 을 call 하게 된다.
적절한 시기에 do_softirq( ) 된다.
- 3가지 방법으로 bottom를 수행할수 있다.
softirq : run 시 성능이 좋다. 그러나 code는 어렵다. open_softirq ()을 호출
tasklet : DECLARE_TASKLET() 을 호출
work queue : DECLARE_WORK() 을 호출
&. Softirg
보통 하드웨어가 request을 요청하여 인터럽트가 수행되는데 softirq 는 소프트 interrupt handler가 request 한 것이다.
softirq_pending의 종류는 총 32비트 이지만 리눅스에서는 5가지만 사용된다.
softirq_pending[0] : HI_SOFTIRQ
softirq_pending[1] : TIMER_SOFTIRQ
softirq_pending[2] : NET_TX_SOFTIRQ
NET_RX_SOFTIRQ
softirq_pending[3] : SCSI_SOFTIRQ
softirq_pending[4] : TASKLET_SOFTIRQ
struct softirq_action에서 보면 pending 된 값이 action data을 찾아서 일을 하게 되는 과정이 (* action)(struct softirq_action*) 을 보면 알수 있다.
@ do_softirq( )
asmlinkage void do_softirq(void)
{
int max_restart =MAX_SOFTIRQ_RESTART;
_u32pending;
// 32비트의 pending
unsigned longflags;
if(in_unterrupt())return;
local_irq_save(flags);
penging = local_softirq_pending();
//pending 은 local value 인데, sotfirq_pending의 값을 clear 시켜준다.
if(penging){ // pending 이 0 가 아니면 수행
struct softirq_action *h;
local_bh_disable();
restartlocal_softirq_pending() = 0;
local_irq_enable();
h = softirq_vec;
// h는 softirq_vec 의 첫 번째 주소를 가르킨다.
do{
if(pending & 1) // 가장 오른쪽에 있는 비트를 검사하게 된다.
h ->action(h);
// h는 포인터로 주소를 가르킨다. handler pointer
h++;
pending >>=1;
} while(pending);
local_irq_disable();
...............
}
=> do_softirqpending을 체크하여 1이면 softirq_vec 의 해당 action을 따라가서 그 수행을 하게 되는 것이다.
& tasklet
전문가가 아닐 경우는 거의 Tasklet 을 사용한다. softirq는 동시 수행 가능하기 때문에 성능이 높지만 tasklet은 cpu가 같은 함수를 call 하지 못한다.
task_head
state
count
*func
data
next
state
count
*func
data
next
tasklet_vec( cpu) (tasklet_struct)
cpu1
cpu2
state는 상태를 나타내는 것으로 0 과 1로 표기되면 0일때는 run, 1일때는 pending 상태이다.
cpu 마다 tasklet_hi_action ,tasklet_action 를 가지고 있다.
리눅스 소스에는 static void tasklet_hi_action(struct softirq_action *a) 와 static void tasklet_action(struct softirq_action *a)에서 정의 하고 있다. tasklet_schedule 은 수행중인 cpu #을 받아 온다.
@asklet_action
static void tasklet_action(struct softirq_action *a)
{
struct tasklet_struct *list;
local_irq_disable();
list = __get_cpu_var(tasklet_vec).list;
__get_cpu_var(tasklet_vec).list = NULL;
// list = tasklet_vec = null
local_irq_enable();
while (list) // list에 각 tasklet이 있는 동안
{
struct tasklet_struct *t = list;
list = list->next;
if (tasklet_trylock(t))
{ // disable 이면
if (!atomic_read(&t->count)) {
if (!test_and_clear_bit(TASKLET_STATE_SCHED, &t->state))
BUG();
t->func(t->data);
tasklet_unlock(t)
continue;
}
tasklet_unlock(t);
}
local_irq_disable();
t->next = __get_cpu_var(tasklet_vec).list;
__get_cpu_var(tasklet_vec).list = t;
__raise_softirq_irqoff(TASKLET_SOFTIRQ);
local_irq_enable();
}
}
&. workqueue
process context으로 독자적인 동작 한다. 세미포어, block I/o 도 사용가능하다. 프로그래밍이 쉽고 tasklet, softirq 와 비교해서는 느리다.

키워드

  • 가격2,000
  • 페이지수14페이지
  • 등록일2008.03.24
  • 저작시기2007.11
  • 파일형식한글(hwp)
  • 자료번호#457308
본 자료는 최근 2주간 다운받은 회원이 없습니다.
청소해
다운로드 장바구니