본문 바로가기

전체 글

(5)
[운영체제][OSTEP] 06. Meachanism: Limited Direct Execution - System Call과 Trap 물리적인 CPU가 하나임에도 불구하고 여러 프로세스가 동시에 실행되는것 처럼 보이게 하려면(virtualize the cpu), 어떻게 해야 할까? 기본 아이디어는 간단한다. 바로 시분할(time sharing) 이다. 한 프로세스를 잠깐 실행하고, 잠시 멈추고, 다른 프로세스를 잠깐 실행하는 것을 계속해서 반복하는 것이다. 하지만 이러한 가상화에는 몇 가지 고려 사항이 있다. 첫 번째는 성능(Performance)이다. 시분할을 구현했을 때, 과중한 오버헤드가 발생하면 컴퓨터의 속도가 느려질 것이다. 두 번째는 프로세스에 대한 제어(Control)이다.프로세스는 필연적으로 메모리나 CPU, I/O Device와 같은 리소스를 사용한다. 프로세스가 리소스를 사용하는 것을 통제할 수 있어야 한다. 제어권을..
[운영체제][OSTEP] 06. Meachanism: Limited Direct Execution - Switching Between Process 이전 글에서는 시스템 콜이 왜 필요한지, 그리고 시스템 콜을 호출하기 위한 Trap이 어떻게 이루어지는지 알아보았습니다.이번에는 프로세스 간 전환이 실제로 어떻게 이루어지는지 알아볼 것입니다.사실 프로세스 전환은 얼핏 보면 간단합니다. 단순히 한 프로세스를 잠깐 멈추고, 다른 프로세스를 시작하면 됩니다.문제는 (컴퓨터가 하나의 CPU만 가지고 있다고 가정하면) 프로세스가 실행되는 동안 프로세스는 CPU를 점유하고 있는 상태이고, 그도안 운영체제는 실행되지 않고 있다는 사실입니다. CPU는 결국 한번에 하나의 명령어밖에는 처리하지 못하기 때문입니다. 당연하게도 운영체제가 실행되지 않고 있다면, 운영체제가 무엇가를 하는 것은 불가능합니다.그렇다면 어떻게 프로세스를 멈추고 운영체제로 제어를 되찾아올 수 있을까..
[운영체제][OSTEP][과제] 05. Process API (Code) 1. Write a program that calls fork(). Before calling fork(), have the main process access a variable (e.g., x) and set its value to something (e.g., 100). What value is the variable in the child process? What value is the variable in the child process? What happes to the variable when both the child and parent change the value of x?#include #include #include #include // Function for formattingvo..
[운영체제][OSTEP][과제] 05. Process API (Simulation) 1. Run./fork.py-s 10 and see which actions are taken. Can you predict what the process tree looks like at each step? Use the -c f lag to check your answers. Try some different random seeds (-s) or add more actions (-a) to get the hang of it. 프로세스의 fork 및 exit 과정이 주어졌을 때 프로세스 트리가 어떻게 생겼는지 추정하는 문제이다. 생략! 2. One control the simulator gives you is the fork-percentage, controlled by the -f flag. The ..
[운영체제][OSTEP][과제] 04. The abstraction: The process (CPU-Intro) Q1. Run process-run.py with the following flags: -l 5:100,5:100. What should the CPU utilization be (e.g., the percent of time the CPU is in use?) Why do you know this? Use the -c and -p flags to see if you were right. A1. CPU의 Utilization은 100%일 것이다. I/O 요청이 없는 프로세스가 연달아 실행되기 때문이다.Time PID: 0 PID: 1 CPU IOs 1 RUN:cpu READY 1 2 ..