[OS] 프로세스의 이해

📝 1yangsh·2021년 7월 2일
0

Process

A process is a program in execution.
즉, 작업중인 작업단위

  • 디스크에 있는 프로그램을 메모리에 올려놓으면 프로세스.
  • 각 프로세스가 CPU를 점유하며 실행된다.

Memory layout of a process

  • Text section
    • the executable code
  • Data section
    • global variables
  • Heap section
    • memory that is dynamically allocated during program run time
    • 예) C 에서는 malloc, Java 에서는 new 등
  • Stack section
    • temporary data storage when invoking functions
    • such as function parameters, return addresses and local variables

Process state

  • New
    • process가 생성된 단계
    • fork() 이후 프로세스 생성
  • Running
    • 프로세스가 CPU를 점유하고 있는 단계
  • Waiting
    • 실행중인 프로세스가 event로 인해 다시 CPU 점유를 대기하고 있는 상태
  • Ready
    • I/O completion 이후 Ready Queue에서 CPU 점유를 대기함
  • Terminated
    • 실행 종료

프로세스 관리

  • PCB (Process Control Block)

    • 구조체에 프로세스가 필요한 정보를 저장
    • PCB가 저장하고 있는 정보
      • Process state
      • Program counter
      • CPU registers
      • CPU-scheduling information
      • Memory-management information
      • Accounting information
      • I/O status information


A process is a program that performs a single thread of execution.

A thread is a lightweight process.

Context Switching

  • PCB 정보를 Context 라고 한다.
  • Context Switching 은 CPU core를 다른 프로세스에게 스위치 하는 것
  • 현재 프로세스의 상태(context)를 저장하고 새로 획득할 프로세스의 상태를 복원
profile
개발 경험 저장소

0개의 댓글