Presentation is loading. Please wait.

Presentation is loading. Please wait.

Lecture #3 프로세스(Process).

Similar presentations


Presentation on theme: "Lecture #3 프로세스(Process)."— Presentation transcript:

1 Lecture #3 프로세스(Process)

2 강의 내용 1. 프로세스(Process) 란? 2. 프로세스 상태(Process State)
1) 2-상태 프로세스 상태 모델 2) 5-상태 프로세스 상태 모델 3) 7-상태 프로세스 상태 모델 3. 프로세스 이미지(Process Image) 4. 프로세스 제어 블록(PCB) 5. 프로세스 스케줄링 6. 프로세스 전환(Context Switching) 7. 프로세스 생성 & 종료 Operating System

3 프로세스(Process)(1) “Task(태스크)” 실행중인 프로그램
프로그램의 실행 메모리 이미지 프로그램 – 수동적인 실체 프로세스 – 능동적인 실체 : trace 가능 윈도우 환경에 아래아한글 프로그램을 두 번 실행하는 경우: 하드 디스크에 저장된 아래아한글 프로그램: 프로그램 두개의 아래아한글 윈도우: 프로세스 모든 multitasking OS는 ‘프로세스’ 개념 을 바탕으로 동작한다 프로세스는 시분할 시스템의 작업 단위 Operating System

4 프로세스(Process)(2) 주기억장치 보조기억장치 운영체재 아래아한글 프로세스 1 아래아한글 프로그램 아래아한글
프로세스 2 Operating System

5 Dispatcher (short-term scheduler)
프로세서(CPU)를 하나의 프로세스에서 다른 프로세스로 옮겨주는 OS 프로그램 스케줄링 알고리즘을 바탕으로 다음에 실행될 프로세스를 결정한다 하나의 프로세스가 CPU 시간을 독점하는 것을 막는다 프로세스 A에서 프로세스 B 로 실행 전환하는 동안에 CPU는 dispatcher 프로그램을 실행한다 Operating System

6 프로세스 상태(Process States)(1)
2-상태 프로세스 모델 Running state / Not-Running state Dispatch Enter Not Running Running Exit Pause (a) State transition diagram Queue Processor Enter Dispatch Exit Pause (b) Queuing diagram Operating System

7 프로세스 상태(Process States)(2)
5-상태 프로세스 모델: The Running state(실행) CPU를 할당받아 명령어를 실행중인 상태 The Ready state(준비) CPU를 할당받기 위해 준비중인 상태 The Blocked(Waiting) state(대기) 어떤 사건이 일어나기를 기다리고 있는 상태(대기상태) (ex: the completion of an I/O) Operating System

8 프로세스 상태(Process States)(3)
The New state(생성) 프로세스 생성 단계 운영체제는 프로세스 생성에 필요한 작업을 수행: 프로세스 식별자(process identifier) 생성 프로세스 테이블(process table) 항목 생성 프로세스 실행이 아직 허용되지 않은 상태 프로그램이 메모리에 적재되지 않은 상태 제한된 자원에 대한 승인 제어 Operating System

9 프로세스 상태(Process States)(4)
The Exit(Terminated) state(종료) 프로그램 실행 종료 단계 프로그램이 메모리에서 해제된 상태 프로세스에 대한 테이블 정보 및 기타 정보는 잠시 유지된다 예: accounting program that cumulates resource usage for billing the users 데이터가 더 이상 필요 없는 경우에 프로세스가 삭제된다 Operating System

10 프로세스 상태 전이 (Process Transitions) (1)
Ready  Running dispatcher가 실행하기 위해 하나의 프로세스를 선택하면 프로세스는 ready 상태에서 running 상태로 전환된다 Running  Ready running 상태의 프로세스에 할당된 time slot이 끝난 경우 더 높은 우선순위 프로세스가 ready 상태로 들어오는 경우 Operating System

11 프로세스 상태 전이 (Process Transitions) (2)
Running  Blocked 실행중인 프로세스가 기다려야 하는 사건(event)을 요구하는 경우: 아직 준비되지 않은 자원에 대한 접근 입출력 동작을 시작하고 종료를 기다리는 경우 다른 프로세스가 입력을 제공하기를 기다리는 경우(IPC) Blocked  Ready 기다리는 사건이 발생하였을 경우 Operating System

12 A Five-state Process Model
Ready to exit: A parent may terminate a child process Operating System

13 스와핑(swapping)의 필요성 “suspend(일시정지)” 상태가 필요
5-상태 프로세스 모델에서는 대기(blocked) 상태의 프로세스까지 주기억장치를 점유한다 가상메모리를 사용하는 경우에도 주기억장치에 너무 많은 프로세스를 올리는 경우 시스템 성능을 저하 시킨다 “suspend(일시정지)” 상태가 필요 대기 상태의 프로세스를 디스크 장치로 스와핑(swapping) Blocked Suspend 디스크 장치로 스와핑된 blocked processes Ready Suspend 디스크 장치로 스와핑된 ready processes Operating System

14 프로세스 상태 전이 (3) Blocked  Blocked Suspend
메모리 상의 모든 프로세스가 대기 상태가 되면 새로운 준비 상태의 프로세스를 가져오기 위한 메모리 공간을 확보하고자 하는 경우 pp. 141, 표 3.4 참조 Blocked Suspend  Ready Suspend 기다리던 사건이 일어나는 경우 Ready Suspend  Ready 메모리에 더 이상 준비 상태의 프로세스가 없는 경우 Ready  Ready Suspend (unlikely) 대기 상태의 프로세스가 없는데 메모리 공간이 필요한 경우 Operating System

15 A Seven-state Process Model
Operating System

16 Trace of Process Sequence of instruction that execute for a process
Dispatcher switches the processor from one process to another Operating System

17 Example Execution Operating System

18 Trace of Processes Operating System

19 Operating System

20 Requirements of an Operating System
Process Execution Interleaving - Interleave the execution of multiple processes to maximize processor utilization while providing reasonable response time Resource Allocation - Allocate resources to processes Interprocess Communication - Support interprocess communication and user creation of processes Operating System

21 Processes and Resources
Operating System

22 Operating System Control Structures
Information about the current status of each process and resource Tables are constructed for each entity the operating system manages Operating System

23 Memory Tables Allocation of main memory to processes
Allocation of secondary memory to processes Protection attributes for access to shared memory regions Information needed to manage virtual memory Operating System

24 I/O Tables I/O device is available or assigned Status of I/O operation
Location in main memory being used as the source or destination of the I/O transfer Operating System

25 File Tables Existence of files Location on secondary memory
Current Status Attributes Sometimes this information is maintained by a file management system Operating System

26 Process Table Where process is located
Attributes in the process control block Program Data Stack Operating System

27 Process Image Operating System

28 Operating System

29 프로세스 이미지 (Process Image) (1)
User program User data Stack(s) for procedure calls and parameter passing 프로세스 제어 블록(Process Control Block: PCB) 운영체제가 프로세스를 관리하기 위해 필요한 정보: Process identification information Processor state information Process control information Operating System

30 프로세스 이미지(2) Operating System

31 프로세스 이미지(3) 각각의 프로세스 이미지는 가상 메모리 상에 존재한다
연속적인 메모리 공간에 할당될 필요가 없다 전용 메모리와 공유 메모리 둘 다 사용한다 프로세스 이미지의 주소는 Primary Process Table의 프로세스별 항목에 저장한다 운영체제가 프로세스를 관리하기 위해서 프로세스 이미지 전부를 메모리에 올릴 필요는 없다 Operating System

32 프로세스 제어 블록(PCB)(1) 프로세스 식별 정보 유일한 프로세스 식별자 (always)
primary process table에 대한 인덱스 사용자 식별자 작업을 실행시킨 사용자에 대한 식별 정보 부모 프로세스 식별자 현재 프로세스를 생성하는 프로세스(Parent Process)의 식별자 Operating System

33 프로세스 제어 블록(PCB)(2) 프로세스 상태 정보 Contents of processor registers
프로세스 실행 상태를 표시하는 정보 주로 프로세서(CPU) 상태 정보 Contents of processor registers User-visible registers Control and status registers Stack pointers Program status word (PSW) processor status information Operating System

34 프로세스 제어 블록(PCB)(3) 프로세스 제어 정보 스케줄링 및 상태 정보 데이터 구조 정보
프로세스 스케줄링 및 제어에 필요한 정보 스케줄링 및 상태 정보 프로세스 상태 (ie: running, ready, blocked...) 프로세스 우선순위 대기 상태에 있는 사건 (if blocked) 데이터 구조 정보 process queues parent-child relationships other structures etc. Operating System

35 프로세스 제어 블록(PCB)(4) 프로세스 제어 정보(계속)
프로세스간 통신 정보 may hold flags and signals for IPC 프로세스 특권 정보 Ex: access to certain memory locations... 메모리 관리 정보 pointers to segment/page tables assigned to this process 자원 소유 및 이용 정보 resource in use: open files, I/O devices... history of usage (of CPU time, I/O...) Operating System

36 Queues as linked lists of PCBs
Operating System

37 프로세스 스케줄링 실행중이 아닌 프로세스는 준비 큐(queue) 또는 대기 큐에서 상태 전이를 기다린다
준비 큐에서는 다음에 실행한 프로세스를 결정한다 - short-term scheduling 대기 큐에서는 각 프로세스가 사건이 발생하기를 기다린다 중지(suspend) 상태의 프로세스 중에서 준비 상태로 전환할 프로세스를 결정한다 - mid-term scheduling Operating System

38 큐잉 원리 – Using Two Queues Operating System

39 큐잉 원리 – Using Multiple Queues
Operating System

40 프로세스 전환(Process Switching)(1)
운영체제가 CPU 제어권을 할당 받을 때마다 프로세스 전환이 발생한다 Supervisor Call(시스템 호출) explicit request by the program (ex: file open). The process will probably be blocked Trap An error resulted from the last instruction. It may cause the process to be moved to the Exit state Interrupt the cause is external to the execution of the current instruction. Operating System

41 프로세스 전환(Process Switching)(2)
인터럽터 예: Clock process has expired his time slice and is transferred to the ready state I/O first move the processes waiting for this event to the ready (or ready suspend) state then resume the running process or choose a process of higher priority Memory fault memory address is in virtual memory so it must bring corresponding block into main memory thus move this process to a blocked state (waiting for the I/O to complete) Operating System

42 프로세스 전환 절차 “문맥 교환(Context Switch)”
프로그램 카운터와 다른 레지스터을 포함한 프로세서 문맥을 저장한다 현재 수행중인 프로세스의 PCB을 새로운 상태 정보와 관련 정보로 수정한다 PCB을 적절한 큐에 이동한다 실행을 위해 다른 프로세스를 선택한다 선택된 프로세스의 PCB를 수정한다 선택된 프로세스의 PCB로부터 새로운 프로세서 문맥을 적재한다 Operating System

43 프로세스 생성(Process Creation)
일괄작업(batch job) 실행 User logs on 사용자에게 제공되는 OS 서비스(ex: printing a file) 하나의 프로세스에서 새로운 프로세스로의 확장 사용자 프로그램은 여러 개의 프로세스을 생성할 수 있다 부모 프로세스(Parent Process) / 자식 프로세스(Child Process) Operating System

44 프로세스 생성 동작 유일한 프로세스 식별자를 할당 프로세스 이미지를 위한 메모리 영역을 할당
PCB(process control block) 초기화 많은 초기값 지정(ex: state is New, no I/O devices or files...) 이외는 부모 프로세스 내용을 복사 적절한 연결을 설정 예: 새로운 프로세스를 스케줄링 큐에 추가한다 Operating System

45 프로세스 종료(Process Termination)
일괄작업(Batch job)에서의 Halt instruction 사용자 로그오프(User logs off) 프로세스에 대한 종료 요구(Termination Request) Error and fault conditions Operating System

46 프로세스 종료 요구(1) Normal completion Time limit exceeded Memory unavailable
Memory bounds violation Protection error example: write to read-only file Arithmetic error Time overrun process waited longer than a specified maximum for an event Operating System

47 프로세스 종료 요구(2) I/O failure Invalid instruction Privileged instruction
happens when try to execute data Privileged instruction Operating system intervention such as when deadlock occurs Parent request to terminate one offspring Parent terminates, so child processes terminate Operating System

48 Execution of the Operating System
Non-process Kernel Execute kernel outside of any process Operating system code is executed as a separate entity that operates in privileged mode Execution Within User Processes Operating system software within context of a user process Process executes in privileged mode when executing operating system code Operating System

49 Operating System


Download ppt "Lecture #3 프로세스(Process)."

Similar presentations


Ads by Google