프로세스란 무엇인가 ..공부해보자.

 

Process Descriptor : 한 프로세스와 관련된 모든 정보를 담고 있는 task_struct 자료구조?

                             리스트의 각 task task_struct를 프로세스 디스크립터라한다.

 

 ?? 커널은 task_t 데이터 타입을 struct task_struct 와 같은 것으로 정의?

 

   Figure 3.1. The process descriptor and task list.

 

 

 

 

Figure 3.3 Flow chart of process states

 

 

0 :TASK_RUNNIG

1 :TASK_INTERUPTIBLE

2: TASK_UNINTERRUPTIBLE

4: TASK_STOPPED

   - 프로세스 실행 중단.  SIGSTOP  , SIGTSTP, SIGTTIN, SIGTTOU 일 경우

8: TASK_TRACED

16: EXIT_ZOMBIE

  - 프로세스가 종료되었지만 부모프로세스가 wait4() , waitpid() 시스템 콜을 호출하여 종료 프로세스의 정보를 반환하지 않은 경우         -----------보충

32: EXIT_DEAD

  -  보충----------------

64: TASK_DEAD

128 : TASK_WAKEKILL

256 : TASK_WAKING

커널에서는 set_task_state    ,   set_current_state 매크로를 사용하여 프로세스의 상태를 설정

 

같은 그룹에 있는 스레드의 PID 가 같은가?  표준을 위해 리눅스는(Thread Group) 도입. 스레드들이 공유하는 식별자는 스레드 그룹의 리더, 즉 그룹 내 첫 번째 경량 프로세스의PID이며 프로세스 디스크립터의 tgid 필드에 저장된다. getpid() 시스템콜은 pid값 대신 tgid 값을 반환하므로 멀티스레드 애플리케이션의 모든 스레드는 같은 식별자를 공유한다. 대부분의 프로세스는 구성원이 1개인 스레드 그룹에 속하므로 tgid 필드는 pid 필드와 값이 같다..QQ~~.....?????????????????????????????

다시정리하자. 모르겠다.

 

thread_info 구조체(arch/x86/include/asm/thread_info.h)프로세스의 저수준(Low-level) 정보

 104P 이해불가.

 struct thread_info {
    struct task_struct  *task;                   /* main task structure */
    struct exec_domain  *exec_domain;   /* execution domain */
    __u32           flags;                          /* low level flags */
    __u32           status;                       /* thread synchronous flags */
    __u32           cpu;                         /* current CPU */
    int         preempt_count;               /* 0 => preemptable,
                           <0 => BUG */
    mm_segment_t        addr_limit;
    struct restart_block    restart_block;
    void __user     *sysenter_return;
#ifdef CONFIG_X86_32
    unsigned long           previous_esp;   /* ESP of the previous stack in case of nested (IRQ) stacks */       
    __u8            supervisor_stack[0];
#endif
    int         uaccess_err;
};

 

--------------arm-----------

/*
 * low level task data that entry.S needs immediate access to.
 * __switch_to() assumes cpu_context follows immediately after cpu_domain.
 */
struct thread_info {
    unsigned long       flags;             /* low level flags */                           8
    int         preempt_count;              /* 0 => preemptable, <0 => bug */       4
    mm_segment_t        addr_limit;     /* address limit */                            
    struct task_struct  *task;             /* main task structure */                     4
    struct exec_domain  *exec_domain;   /* execution domain */                 4
    __u32           cpu;                           /* cpu */                                     4
    __u32           cpu_domain;               /* cpu domain */                           4
    struct cpu_context_save cpu_context;    /* cpu context */
    __u32           syscall;                          /* syscall number */                  4
    __u8            used_cp[16];                  /* thread used copro */              1
    unsigned long       tp_value;                                                                8
    struct crunch_state crunchstate;              
    union fp_state      fpstate __attribute__((aligned(8)));
    union vfp_state     vfpstate;
#ifdef CONFIG_ARM_THUMBEE
    unsigned long       thumbee_state;  /* ThumbEE Handler Base register */
#endif
    struct restart_block    restart_block;
};

        

http://m.blog.daum.net/english_100/71     참고이해하도록

 

 

 

프로세스 디스크립터 포인터(Process Descriptor Pointer)를 통해 프로세스를 참조한다.

 

참고 : 그림및 내용 http://www.makelinux.net/books/lkd2/ch03lev1sec1

         리눅스 커널의 이해(개정 3판)

         커널 최초의 스택은 어떻게 설정하나요?

         http://forum.falinux.com/zbxe/index.php?document_srl=551428&mid=lecture_tip

 

'리눅스커널' 카테고리의 다른 글

systemcall  (0) 2015.04.15
스와퍼(Swapper)프로세스  (0) 2015.04.15
schedule()함수  (0) 2015.04.15
프로세스1-3  (0) 2015.04.14
불연속메모리할당  (1) 2015.04.10

+ Recent posts