[OS] Process, Process Control Block, Process Scheduling

Ko Hyejung·2021년 10월 11일
0

Operating Systems

목록 보기
7/26

What is a process?

+) 프로세스는 일반적으로 프로세서에 의해 처리되는 사용자 프로그램, 시스템 프로그램,
즉 실행중인 프로그램을 의미하여 job, task라고도 부름

Process is a program in execution. 프로세스는 실행 중인 프로그램

A program is a passive entity. 프로그램은 passive 엔티티

(e.g., a file containing a list of instructions stored on disks (executable file))
(예: 디스크에 저장된 명령 목록이 들어 있는 파일(복제 파일)

A process is an active entity with a program counter.
프로세스는 프로그램 카운터가 있는 active 엔티티

A program becomes a process when an executable file is loaded into memory.
실행 파일이 메모리에 로드되면 프로그램이 프로세스 됨

Multiple processes can be created by a program.
프로그램에 의해 여러 프로세스를 만들 수 있습니다

Textbook uses job, task and process almost interchangeably.

A process includes, code (or text) section, data section, stack and heap, and program counter.

프로세스에는 code(또는 텍스트) 섹션, data 섹션, stackheap**, 프로그램 카운터가 포함

Process in Memory

Process State

As a process executes, it changes state.

  1. new
    The process is being created.
    A program which is going to be picked up by the OS into the main memory is called a new process.

OS가 메인 메모리로 가져오는 프로그램을 새 프로세스라고 합니다.

  1. ready
    The process is waiting to be assigned to the CPU.
    Whenever a process is created, it directly enters in the ready state, in which, it waits for the CPU to be assigned.
    The OS picks the new processes from the secondary memory and put all of them in the main memory.
    The processes which are ready for the execution and reside in the main memory are called ready state processes.
    There can be many processes present in the ready state.

프로세스가 생성될 때마다 프로세스가 준비 상태로 직접 전환되고, 이 상태에서 CPU가 할당될 때까지 기다립니다.
OS는 보조 메모리에서 새로운 프로세스를 선택하여 모든 프로세스를 메인 메모리에 넣습니다.
실행 준비가 되어 있고 주 메모리에 상주하는 프로세스를 준비 상태 프로세스라고 합니다.
준비 상태에는 많은 프로세스가 존재할 수 있습니다.

  1. running
    Instructions are being executed.
    One of the processes from the ready state will be chosen by the OS depending upon the scheduling algorithm.
    Hence, if we have only one CPU in our system, the number of running processes for a particular time will always be one.
    If we have n processors in the system then we can have n processes running simultaneously.

준비 상태의 프로세스 중 하나는 스케줄링 알고리즘에 따라 OS에 의해 선택됩니다.
따라서 시스템에 CPU가 하나만 있는 경우 특정 시간 동안 실행 중인 프로세스의 수는 항상 하나가 됩니다.
시스템에 n개의 프로세서가 있다면 n개의 프로세스를 동시에 실행할 수 있습니다.

  1. waiting
    The process is waiting for some event to occur.
    From the Running state, a process can make the transition to the block or wait state depending upon the scheduling algorithm or the intrinsic behavior of the process.
    When a process waits for a certain resource to be assigned or for the input from the user then the OS move this process to the block or wait state and assigns the CPU to the other processes.

프로세스가 일부 이벤트가 발생하기를 기다리고 있습니다.
실행 상태에서 프로세스는 스케줄링 알고리즘 또는 프로세스의 고유 동작에 따라 블록 또는 대기 상태로 전환할 수 있습니다.
프로세스가 특정 리소스를 할당하거나 사용자의 입력을 기다릴 때 OS는 이 프로세스를 블록 또는 대기 상태로 이동하고 CPU를 다른 프로세스에 할당합니다.

  1. terminated
    The process has finished execution.
    When a process finishes its execution, it comes in the termination state.
    All the context of the process (Process Control Block) will also be deleted the process will be terminated by the Operating system.

프로세스가 실행을 마치면 종료 상태가 됩니다.
프로세스의 모든 컨텍스트(프로세스 제어 블록)도 운영 체제에 의해 삭제됩니다.

Process Control Block (PCB)

+) 운영체제가 프로세스에 대한 중요한 정보를 저장하는 곳
각 프로세스가 생성될 때마다 고유의 PCB가 생성되며 프로세스가 완료되면 제거된다

Information associated with each process (also called task control block (TCB)).
각 공정과 관련된 정보( 작업 제어 블록(TCB))

  • Process state 프로세스 상태
  • Process number 공정 번호
  • Program counter 프로그램 카운터
  • CPU registers
  • CPU scheduling information
  • Memory-management information 메모리 관리 정보
  • Accounting information
  • I/O status information

Process Control Block in Linux

Concept of Process Scheduling

The objective of multiprogramming is to have some process running at all times, to maximize CPU utilization.

멀티프로그래밍의 목적은 CPU 활용률을 극대화하기 위해 일부 프로세스를 항상 실행하는 것

The objective of time-sharing is to switch the CPU among processes so frequently that users can interact with each program.

시간 공유의 목적은 프로세스 간에 CPU를 너무 자주 전환하여 사용자가 각 프로그램과 상호 작용할 수 있도록 하는 것

A uni-processor system can have only one running process.
유니 프로세서 시스템에는 실행 중인 프로세스가 하나만 있을 수 있습니다.

If more processes exist, the rest must wait until the CPU is free and can be rescheduled => This requires process scheduling.

프로세스가 더 있는 경우 나머지는 CPU가 사용 가능할 때까지 기다려야 하며 => 다시 예약할 수 있습니다.
이 경우 process scheduling이 필요

The # of processes currently in memory is known as the degree of multiprogramming.

Processes can be described as either:

  • I/O-bound process spends more time doing I/O than computations.
    I/O-bound 프로세스는 계산보다 I/O에 더 많은 시간을 소비
  • CPU-bound process generates I/O infrequently, using more time doing computations.
    CPU 바운드 프로세스는 계산을 수행하는 데 더 많은 시간을 사용하여 I/O를 자주 생성하지 않습니다

+) https://www.tutorialspoint.com/operating_system/os_process_scheduling.htm

The process scheduling is the activity of the process manager that handles the removal of the running process from the CPU and the selection of another process on the basis of a particular strategy.

프로세스 스케줄링은 CPU에서 실행 중인 프로세스의 제거와 특정 전략을 기반으로 다른 프로세스의 선택을 처리하는 프로세스 관리자의 활동입니다.

Process scheduling is an essential part of a Multiprogramming operating systems.
Such operating systems allow more than one process to be loaded into the executable memory at a time and the loaded process shares the CPU using time multiplexing.

프로세스 예약은 멀티프로그래밍 운영 체제의 필수적인 부분입니다.
이러한 운영 체제는 한 번에 둘 이상의 프로세스를 실행 가능한 메모리에 로드하고 로드된 프로세스는 시간 멀티플렉싱을 사용하여 CPU를 공유합니다.

Process Scheduling Queues


Ready queue
set of all processes residing in main memory, ready and waiting to execute.

준비 대기열
주 메모리에 상주하고 실행 대기 중인 모든 프로세스 집합

Device queues (I/O wait queue)
set of processes waiting for an I/O device.

장치 대기열(I/O 대기 대기열)
I/O 장치를 기다리는 프로세스 집합입니다.

The OS maintains all PCBs in Process Scheduling Queues.
The OS maintains a separate queue for each of the process states and PCBs of all processes in the same execution state are placed in the same queue.

OS는 프로세스 예약 대기열에 있는 모든 PCB를 유지합니다.
OS는 각 프로세스 상태에 대해 별도의 대기열을 유지하며 동일한 실행 상태에 있는 모든 프로세스의 PCB는 동일한 대기열에 배치됩니다.

When the state of a process is changed, its PCB is unlinked from its current queue and moved to its new state queue.

프로세스 상태가 변경되면 PCB는 현재 대기열에서 연결이 해제되고 새 상태 대기열로 이동합니다.

The Operating System maintains the following important process scheduling queues.

운영 체제는 다음과 같은 중요한 프로세스 예약 대기열을 유지합니다.

  1. Job queue
    This queue keeps all the processes in the system.

이 대기열은 시스템의 모든 프로세스를 유지합니다.

  1. Ready queue
    This queue keeps a set of all processes residing in main memory, ready and waiting to execute. A new process is always put in this queue.

이 대기열은 기본 메모리에 상주하는 모든 프로세스 집합을 실행 준비 및 대기 상태로 유지합니다. 새 프로세스는 항상 이 대기열에 배치됩니다.

  1. Device queues
    The processes which are blocked due to unavailability of an I/O device constitute this queue.

I/O 장치를 사용할 수 없어 차단된 프로세스가 이 대기열을 구성합니다.

The OS can use different policies to manage each queue (FIFO, Round Robin, Priority, etc.).
The OS scheduler determines how to move processes between the ready and run queues which can only have one entry per processor core on the system; in the above diagram, it has been merged with the CPU.

OS는 서로 다른 정책을 사용하여 각 대기열(FIFO, 라운드 로빈, 우선순위 등)을 관리할 수 있습니다.
OS 스케줄러는 시스템의 프로세서 코어당 하나의 항목만 가질 수 있는 준비 대기열과 실행 대기열 사이에서 프로세스를 이동하는 방법을 결정합니다. 위의 다이어그램에서 CPU와 병합되었습니다.

Schedulers


CPU scheduler selects which process should be executed next and allocates CPU.
CPU 스케줄러는 다음에 실행할 프로세스를 선택하고 CPU를 할당

CPU scheduler is invoked very frequently (milliseconds).
CPU 스케줄러는 매우 자주(밀리초) 호출됨

CPU scheduler with swapping (or paging – will be discussed later) is generally used.
swapping(또는 paging – 나중에 설명함)이 포함된 CPU 스케줄러가 일반적으로 사용됩니다.

The key idea is that sometimes it can be advantageous to remove process from memory (swap out), and at some later time the process can be reintroduced into memory and continues its execution (swap in).

핵심 아이디어는 때때로 메모리에서 프로세스를 제거하는 것이 유리할 수 있고(스왑 아웃), 나중에 프로세스가 메모리에 재도입되어 실행을 계속할 수 있다는 것이다(스왑 인).

Comparison among Schedulers

0개의 댓글