쉐도잉 연습: The Most Successful Idea in Computer Science - YouTube로 영어 말하기 배우기

C1
⏸ 일시 정지
This video was sponsored by Brilliant.
77 문장
문장이 너무 짧거나 길면 Edit를 눌러 조정하세요.
1
This video was sponsored by Brilliant.
2
In a previous episode, we talked about  concurrency. The direction of this channel is now shifting toward lower-level concepts  more closely related to operating systems, such as CPU scheduling, threads,  paging, and virtual memory.
3
The challenge with these topics is that all of them are deeply tied to a concept  we haven’t yet covered in detail.
4
Today we’re going to dive into the  technical details of processes.
5
Hi friends, my name is George.  And this, is core dumped.
6
As we discussed in my previous video, a process  is informally defined as a program in execution, meaning that these two concepts are not the same.
7
A program is a passive entity, such as an executable file that  we can launch to start running.
8
When we run a program, what happens internally is  that its executable file is loaded into memory.
9
At this point, our program becomes a process. The execution of this process though might require additional memory to store  user input and temporary results.
10
The operating system is responsible  for allocating that memory.
11
The memory assigned to it has a special  name: the address space of the process.
12
We’ll return to this concept later  in the video, so keep it in mind.
13
A process, however, is more  than just its address space.
14
As we know, modern operating  systems use concurrency, allowing multiple processes to execute by  alternating access to computer resources.
15
Internally, alternating access to the CPU is  achieved by placing processes in a queue. We'll understand how this work by the end of this video. The key point now is that at any given moment, only one process can use the CPU,  while all others wait their turn.
16
Remember, the CPU has internal components  like general-purpose registers, the instruction register, the address  register (also known as the program counter), the stack pointer, and even flags. When a process gains access to the CPU, it uses these components to manipulate and move  data. This is what running a program essentially is, as we've covered in previous episodes. But, alternating CPU access between multiple processes is not as simple as it sounds. If we simply switch processes, the process that gains access to the CPU would find itself  in a CPU state belonging to the previous process.
17
This leads to two major issues: First, this is a severe security risk since the current process could access  sensitive information from the previous process.
18
I mean, imagine if the previous process was  hashing a password, part of that password could still be stored in the registers. Nothing  would stop the current process from reading that information for malicious purposes. So, the first concern here is security.
19
Now, let’s assume that all processes  are honest and won’t use the information from a previous process. Does that  solve all the problems? Well… no.
20
Even if the current process has no  intention of using that information, it still needs to manipulate the registers  to carry out its own tasks. In doing so, it alters the CPU state of the previous process. So, when the previous process regains CPU access later, the CPU state it had when  it was interrupted would be lost.
21
So, the second concern here  is correctness of execution.
22
This might be a bit difficult to  follow, so let me show you an example.
23
Let’s say we want to run two programs. When compiled to assembly, they look something like this. To be executed by the computer, the  code must first be compiled into machine code.
24
Since binary can be hard to follow, we’ll show the  instructions in assembly for educational purposes.
25
Let’s assume that both programs  are launched at the same time.
26
To run them, they are loaded into memory. And for simplicity, let’s also say the concurrency model used by the operating  system allows each process to execute up to two instructions before switching  CPU access to a different process.
27
To start executing the first process, the  operating system sets the program counter so the CPU can begin fetching  instructions for that process.
28
The first instruction tells the CPU  to load the value 12 into register 0.
29
That’s one instruction. This process can still  execute one more instruction before the operating system reallocates the CPU to the second process. The second instruction tells the CPU to load the value 20 into register 1. That completes two instructions. At this point, the operating system sets the program counter so  the CPU can start executing the second process.
30
Now that the program counter points to  the executable code of the second process, we can say the CPU is allocated to it. Note that while the second process now has control of the CPU, the data the first process was  working with is still present in the registers.
31
Again, we assume this second process is not  malicious and will mind its own business.
32
The first instruction of the second process tells  the CPU to load the value 100 into register 0.
33
That’s one instruction. The next instruction tells the CPU to load the value 35 into register 1. Now two consecutive instructions have been executed, so the operating system must  reallocate the CPU back to the first process.
34
For this, it needs to set the program  counter to the correct address so the first process can continue exactly where it left off. But… first mistake! We didn’t store that address anywhere before allocating the CPU to the second  process, so now we can’t resume the first process.
35
Here’s where things start to go wrong. Let’s assume that the operating system had saved the program counter value  and is able to restore it properly.
36
The first process regains control of the CPU and  continues execution from where it was interrupted.
37
Now the third instruction is telling the  CPU to add the values currently held in registers 0 and 1, which are supposed to be  12 and 20, respectively. However, since the second process modified the registers during its  execution, the CPU will now add the wrong numbers.
38
The CPU, simply following instructions, has no  way of knowing what happened, so it will continue executing the process using the incorrect data. And problems don’t stop there. In this example, the first process overwrites the value in  register 0 during the addition. So, when the operating system reallocates the CPU to the second  process, its CPU state will also be altered.
39
In a similar way, the second process will continue  executing, but it will end up not only adding the wrong values but also storing the wrong result. In the end, we’ve managed to mess up both processes' results. Where the first process should have produced 32, it now gives us 135. And where the second process  should have produced 135, it instead gives us 170.
40
Perhaps the worst part here is that these wrong  values are not deterministic. For example, if we had added a third process, or  if the second program was launched even a few milliseconds later, we would’ve  seen completely different wrong results.
41
This problem becomes a nightmare when we consider  that modern computers handle hundreds of processes at once. And to make matters worse, in practice,  it is extremely difficult to predict the exact order in which processes will execute, as  we’ll learn in the CPU scheduling video.
42
Ok but then, how do operating  systems ensure security and correctness when dealing with multiple processes?
43
Well… the solution requires extra steps. Let’s use the same example: two processes start at the same time. We still allow each  process to execute. For the first process, it loads the value 12 into register 0  and then the value 20 into register 1.
44
After this, the CPU must be  allocated to the second process.
45
But instead of simply overwriting the address  register to make the CPU jump to the executable code of the second process, the operating system  first runs a special routine to capture the current state of the CPU—like taking a snapshot. The purpose of this is to copy the contents of the registers, flags, and program  counter into memory so that when the process regains control of the CPU, the state  it had when it was interrupted can be restored.
46
The operating system keeps a copy of the CPU state  for every single process running on the computer.
47
Right after the CPU state of the interrupted  process is captured and safely stored, the CPU state of the next process is restored. In this case, since the second process hasn’t executed any instructions yet, all  of its registers are set to zero, except for the program counter, which points  to the next instruction the process should execute. At this moment, that would be the  first instruction at memory location 1013.
48
Now, the second process starts  executing, loading the value 100 into register 0 and the value 35 into register 1. After two instructions, it is interrupted to allow the CPU to be reallocated to the first process. But once again, before doing that, the CPU state of the second process  is captured and safely stored.
49
Only after storing this information does  the operating system retrieve the state of the first process and copy it into  the corresponding registers in the CPU.
50
By doing this, each time a process regains  control of the CPU, it will find the registers exactly as they were when it was interrupted. This process resolves both problems. A process can no longer access the information the previous  process was using, and since its own state hasn’t been altered by the other process, it can  continue execution with the confidence that it is working with the correct data. This action of capturing the CPU state of a process and restoring the state of  a different process so it can continue execution is known as a context switch. And this is how operating systems guarantee security and correctness when  sharing the CPU among multiple processes.
51
Ok, so, now we already know that a process  has an address space, a program counter, and registers, which can be informally  defined as the CPU state of the process.
52
But what else does a process have? Well, a process might also have a list of open files, as well as IO devices allocated to it. This is the simplest way we can visualize a process. As you can see, instead of being a single entity, a process is this  entire context, isolated from other processes.
53
And that’s the best way we cand describe  a process with a single word: A context.
54
This is why the kernel routine we learned  about earlier is called a context switch.
55
When we switch processes, we are replacing the  entire context in which the system operates.
56
This also explains, from a high-level  perspective, why multiple processes can have the same executable instructions but  still produce different results when executed.
57
It’s not only about the instructions but also the  context in which those instructions are executed.
58
Have you ever asked someone a question  and received the reply, “In what context?” When someone responds this way, it’s because the same question can have  different answers depending on the situation.
59
The question that arises now is: if a process is  this entire context, from low-level components like registers to higher-level things like a  list of files, how can we put them in a queue?
60
I mean, a process isn’t like an object we can  simply use as an element in a data structure. So, how do we manage this? The answer is the PCB.
61
No, not that PCB. In this case, PCB stands for Process Control Block, a special structure the operating  system uses to keep track of every single process.
62
Since every process is unique, it requires  an identifier, known as a process ID.
63
A process also has a state, which can  be any of several possible statuses.
64
We’ll discuss these in more detail shortly. In addition, a process has a program counter, a list of general-purpose registers, an  instruction register, and flags. Depending on the hardware, a process might also have a  stack pointer, index registers, accumulators, and other components I won’t list here. This is what I informally refer to as the CPU state of the process. Do you remember that a context switch requires capturing the CPU state for each  process? Well, this is where that data is stored.
65
Regarding memory, the operating  system must also track all the memory blocks allocated to each process. Remember when we mentioned that each process has its own address space? Well, running multiple programs concurrently introduces a new security  issue because, without extra precautions, any process could potentially read from or  write to the address space of another process.
66
The operating system needs to  be aware of these boundaries to intercept any malicious memory access. Additionally, when a new process is created, the operating system needs to be aware of  the address space of each existing process to correctly allocate an available  memory region for the new process.
67
Therefore, the Process Control Block should  contain memory management information, at least including the memory limits  of each process's address space.
68
And here we can also add other  resources allocated to the process, such as a list of IO devices or open files.
69
Now, the structure you’re seeing is just an  example. If you want to see a real implementation, we can look at the source code of  the Linux kernel under this path.
70
The first interesting thing to note is  that the structure is called a task, not a process. I’m not a kernel expert, but I think  it’s called that because Linux was originally inspired by Unix, where it was said that computers  ran tasks. I might be mistaken though, so feel free to correct me in the comments if I’m wrong. The reason is called this way is because Linux uses the term "task" to represent  the fundamental unit of execution, encompassing both threads and processes  within a single data structure, effectively treating them as the  same entity for scheduling purposes.
71
Another interesting thing I noticed when  reviewing the implementation is that the Process Control Block (PCB) contains a  pointer to the PCB of the parent process, as well as a list of all the processes created  by the process represented by the struct.
72
So, I guess we could add  that detail to our example.
73
Again, I want to emphasize that the Process  Control Block is not the process itself, but rather a representation of the process.  It serves as a repository for all the data needed to start or resume a process,  along with some accounting information.
74
And this representation is what  is actually placed in a queue.
75
And at this point, we should be ready to dive  into CPU scheduling, a topic for a future episode.
76
Finally, keep in mind that everything  we’ve cover in this video is valid for single processor systems, and multicore systems.
77
The only different is that multicore  systems can operate with multiple contexts at the same time due to each  core having its own execution pipeline.

앱 다운로드

Everything you need to speak fluently

AI PronunciationScore every sentence
IPA PracticeMaster every sound
VocabularyBuild your word bank
Vocab GameLearn while playing

이 비디오로 영어 회화를 연습해야 하는 이유

이 비디오는 컴퓨터 과학의 가장 성공적인 아이디어를 다루고 있습니다. 기술적인 주제를 다루는 만큼, 어려운 단어와 표현들이 많습니다. 이러한 내용은 영어 회화를 연습하는 데 큰 도움이 되며, 전문 용어를 자연스럽게 문맥 속에서 익힐 수 있는 기회를 제공합니다. 특히 영어 회화 연습에 힘쓰고 있는 분들에게 이 비디오는 실제적인 문장 구조를 배우고, 다양한 기술적 틀에 대해 이야기하는 능력을 향상시키는 데 큰 도움이 될 것입니다. 여기서 제시되는 표현들을 소리내어 읽어보는 것은 영어 쉐도잉의 좋은 예입니다.

문맥 속에서의 문법 및 표현

  • “A process is informally defined as a program in execution”: 이 문장은 '과정(process)'과 '프로그램(program)'의 차이를 설명하면서 프로그래밍 관련 영어 표현을 익히는 데 유용합니다. 간접적으로 영어의 복잡한 정의를 단순화하는 연습이 가능합니다.
  • “The operating system is responsible for allocating that memory”: 이러한 표현은 주어와 동사의 관계를 명확히 하여, 주어가 어떤 작업을 수행하는지 알 수 있도록 돕습니다. 이런 구조를 잘 활용하면 더 다양한 문장을 만들 수 있습니다.
  • “key point now is that at any given moment, only one process can use the CPU”: 이 문장은 특정 시간이나 조건을 설명할 때의 영어 표현을 익힐 수 있는 기회를 제공합니다. 

일반적인 발음 함정

이 비디오에서 몇 가지 발음이 어려운 단어들이 존재합니다. 예를 들어, “CPU”라는 단어는 일반적으로 사람들이 발음하는 방식과는 달리 정확한 기술적 문맥에서는 다양한 포인트(예: '수시로 정보 전달이 되는')로 발음되지 않을 수 있습니다. 또한, 'program'과 'process' 같이 유사하게 발음되는 단어들도 중요합니다. 이처럼 비디오에서 다루는 고유명사와 기술 용어를 shadowspeak 방식으로 따라 해보면 발음 자신감을 키울 수 있습니다.

이 비디오를 통해 여러분은 영어 회화 연습 뿐만 아니라, shadow speech 기술을 통한 효율적인 학습 방법을 체험할 수 있습니다. 이러한 매력적인 과정 속에서 영어를 자연스럽게 활용해보세요!

쉐도잉이란? 영어 실력을 빠르게 키우는 과학적 방법

쉐도잉(Shadowing)은 원래 전문 통역사 훈련을 위해 개발된 언어 학습 기법으로, 다언어 학자인 Dr. Alexander Arguelles에 의해 대중화된 방법입니다. 핵심 원리는 간단하지만 매우 강력합니다: 원어민의 영어를 들으면서 1~2초의 짧은 지연으로 즉시 소리 내어 따라 말하는 것——마치 '그림자(shadow)'처럼 화자를 따라가는 것입니다. 문법 공부나 수동적인 청취와 달리, 쉐도잉은 뇌와 입 근육이 동시에 실시간으로 영어를 처리하고 재현하도록 훈련합니다. 연구에 따르면 이 방법은 발음 정확도, 억양, 리듬, 연음, 청취력, 말하기 유창성을 크게 향상시킵니다. IELTS 스피킹 준비와 자연스러운 영어 소통을 원하는 분들에게 특히 효과적입니다.