OS_Chapter_3.1

ssonjh·2021년 4월 7일
0

OS

목록 보기
15/17

👀 Process Concept

옛날에는 프로그램이 하나씩 실행되었지만, 현재에는 컴퓨터의 발전으로 여러 개의 프로그램이 동시에 실행될 수 있게 되었고, 이를 관리해야 하기 때문에 Process의 개념이 등장하게 되었다.

📕 Process?

  • a program in execution
  • process execution must progress in sequential fashion

Multiple parts

  1. Current activity including program counter, processor registers
  2. text section : The program code
  3. Stack : containing temporary data
    • Function parameters, return addresses, local variables
  4. Data section containing global variables
  5. Heap : containing memory dynamically allocated during run time

Memory Layout of a C Program

Program vs Process

  • Program is passive entity stored on disk (executable file)
  • Process is active
  • Program becomes process when executable file loaded into memory
  • One program can be several processes
    • Consider multiple users executing the same program

  • Execution of program started via GUI mouse clicks,
    command line entry of its name, etc

Summary

Process?

  • 실행중인 프로그램을 뜻한다.
  • 모든 process의 실행은 반드시 순차적인 방식으로 이루어져야 한다.
  • mulit tasking system에서 '작업의 단위'가 되기도 한다.

Multiple parts

  1. 현재 작업에는 program counterprocessor register가 포함된다.
  2. text section : program code를 포함한다.
  3. Stack : 임시적인 data를 포함한다.
    ex) 함수의 매개변수, 복귀 주소, 지역 변수
  4. Data section : 전역 변수를 포함한다.
  5. Heap : 실행 시간 동안 동적할당되는 메모리

Program vs Process

  • Program은 disk에 저장되어 있는 수동적인 존재이다.
  • 반면, Process는 능동적이다.
    실행 파일이 memory로 load되어 실행되면, 그때 program에서 process가 된다.
  • 하나의 program이 여러 개의 process를 가질 수 있다.
    ex) 다수의 user들이 같은 프로그램을 실행시킬 때

📙 Process State

  • As a process executes, it changes state
  • The state of a process is defined in part by the current
    activity of that process.
  1. New : The process is being created
  2. Running : Instructions are being executed
  3. Waiting : The process is waiting for some event to occur
  4. Ready : The process is waiting to be assigned to a processor
  5. Terminated : The process has finished execution

Diagram of Process State

  • It is important to realize that only one process can be running on any processor at any instant.

Summary

  • Process가 실행될 때, 상태가 바뀐다.
  • Process의 상태는 현재 Process의 행동에 따라 정의된다.
  1. New : process가 만들어진 상태
  2. Running : 명령이 실행중인 상태
  3. Waiting : process에서 event가 발생해 기다리는 상태
  4. Ready : processor가 process를 할당해 주기를 기다리는 상태
  5. Terminated : process가 실행을 끝낸 상태

  • 한 순간에 한 processor에서 오직 하나의 process만 실행된다.
    = 많은 process가 Ready 및 Waiting 상태에 있을 수 있다는 것이다.

📒 Process Control Block (PCB)

  • Each process is represented in the OS by a process control block (PCB) (also called task control block)
    • It contains information associated with each process

  • Process state : running, waiting, etc
  • Program counter : location of instruction to next execute
  • CPU registers : contents of all process-centric registers
  • CPU scheduling information : priorities, scheduling queue pointers
  • Memory-management information : memory allocated to the process
  • Accounting information : CPU used, clock time elapsed since start, time limits
  • I/O status information : I/O devices allocated to process, list of open files

Summary

  • 각 process는 OS 내에서 process control block (PCB) (또는 task control block)으로 표현할 수 있다.
    • 각 process와 관련된 정보들을 포함하고 있다.
  • Process state : process의 상태 ex)running, waiting...
  • Program counter : process가 다음에 실행할 명령어의 주소를 가리키고 있다.
  • CPU registers : process 중심의 register에 대한 모든 내용
    (process가 interrupt 발생 시 어디까지 실행되었는지 상태를 담고 있다.)
  • CPU scheduling information : process 우선순위, scheduling queue에 대한 pointer의 정보를 담고 있다.
  • Memory-management information : process의 메모리 할당과 관련된 정보를 담고 있다.
  • Accounting information : CPU 사용 시간, 시작 이후 경과된 clock시간, 시간 제한
  • I/O status information : process에게 할당된 입출력 장치 정보

Threads

현재까지 설명한 process model은 process가 단일의 실행 thread를 가진 프로그램임을 가정했다. 자세한건 Chap.4에서~

Represented by the C structure


dictionary
Instruction 명령
assign 할당
prioritiy 우선순위
Accounting 회계

0개의 댓글