컴파일러 | Source Code -> Object 파일 |
링커 | 여러 Object 파일들과 라이브러리를 연결하여, 메모리로 로드 될 수있는 하나의 Executable로 변환. |
로더 | Executable을 실제 메모리에 올려주는 역할을 담당하는 운영 체제의 일부. |
Object 파일
프로세스로 변환되기 위한 정보가 삽입되어 있음.
Relocatable Address로 표현됨.
Executable
특정한 환경 (OS)에서 수행될 수 있는 파일.
프로세스로의 변환을 위한 header, 작업 내용인 text, 필요한 데이터인 Data를 포함.
Absolute Address로 표현됨.
=> 결과물이 수행될 OS와 CPU에 따라 다른 형태의 파일을 만듦.
메모리에 올리는 과정
Runtime System
프로그램과 연결하여 상호작용함.
ex) C파일 컴파일 및 실행과정
프로세스를 어떠한 기준으로 설계해야 하며, 어떤 것이 필요한가?!
Abstraction for
Execution Unit (스케줄링의 단위)
Protection Domain (서로 침범하지 못함)
Implemented with
Program Counter
Stack
Data Section
(디스크에 저장된 프로그램으로부터 변환되어 메모리로 로딩된 것 - 프로세스)
New : The process is being created
Running: Instructions are being executed
Waiting: The process is waiting for some event to occur (an I/O completion or reception of a signal)
Ready: The process is waiting to be assigned to a processor.
Terminated: The process has finished execution.
커널 내에 ready queue, waiting queue, running queue를 두고 프로세스들을 상태에 따라 관리한다.
cpu slices 방식으로 인해 나타나는 현상
CPU switches to a new process, Kernel must save the state of the old process and load the saved states for the new process.
Context switching time is overhead. CPU time slices를 할당할 수 없음.
Context switching time의 경우,
process management의 scheduling 방식에 따라,
hardware가 지원하는 기능, 방식에 따라 차이가 있을 수 있음.
프로세서 구조에 따라 다르다.
Process Creation
The processes in the system can execute concurrently, and they must be created and terminated dynamically.
// 운영체제 마다 다름.
- parent process vs. child process
: resource sharing 방식과 execution 방식이 운영체제마다 다르다.
예를 들어, Parent가 Child를 안 기다리고 독립적으로 수행될 수 있는 경우, 자원을 공유하지 않는 게 좋다.
Parent에 종속적으로 child가 생성되는 경우는 때때로 parent의 자원을 공유할 필요가 있다.
Process Termination
# 정상적으로 끝나는 경우, OS는 exit system call을 통해 프로그램을 메모리로부터 삭제
A process terminates when it finishes executing its final statement and asks the Operating System to delete it by using exit system call.
# return을 통해 나온 output data가 wait을 통해 parent로 전달됨.
# 정말 error에 의해 abnormal하게 프로세스가 종료되는 경우.
The abort function causes abnormal process termination to occur.
Independent process cannot affect or be affected by the execution of another process.
원래는 다른 process에 의해 관여되면 안되었지만, 서로 다른 프로세스들이 협력해야하는 경우
interprocess communication을 통해 안전하게 공유된 것에 접근할 수 있도록 한다.
[운영체제] 8. 스레드 (0) | 2021.03.23 |
---|
댓글 영역