Luyện nói tiếng Anh bằng Shadowing qua video: The Most Successful Idea in Computer Science

C1
⏸ Tạm dừng
This video was sponsored by Brilliant.
77 câu
Nếu các câu quá ngắn hoặc quá dài, hãy bấm Edit để chỉnh sửa.
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.

Tải Ứng Dụng

Mọi thứ bạn cần để nói trôi chảy

Chấm điểm AIChấm từng câu nói
Luyện IPAThành thạo mọi âm
Từ vựngMở rộng vốn từ
Game Từ vựngHọc qua chơi

Ngữ Cảnh & Bối Cảnh

Trong video này, George đã giới thiệu một chủ đề thú vị liên quan đến khoa học máy tính, đặc biệt tập trung vào khái niệm "quá trình". Ông nhấn mạnh sự khác biệt giữa chương trình và quá trình, cho rằng một chương trình là một thực thể thụ động trong khi quá trình là chương trình đang được thực thi. Nội dung video cung cấp cái nhìn sâu sắc về cách mà các hệ điều hành xử lý và quản lý nhiều quá trình đồng thời, đồng thời giải thích các thách thức liên quan đến an ninh và độ chính xác trong thực thi.

5 Câu Nói Hàng Ngày Hữu Ích

  • "A process is informally defined as a program in execution." - Một quá trình được định nghĩa một cách không chính thức là một chương trình đang được thực thi.
  • "The operating system is responsible for allocating that memory." - Hệ điều hành có trách nhiệm phân bổ bộ nhớ đó.
  • "Only one process can use the CPU at a given moment." - Chỉ có một quá trình có thể sử dụng CPU tại một thời điểm nhất định.
  • "The execution of this process requires additional memory." - Việc thực thi quá trình này cần thêm bộ nhớ.
  • "This action of capturing the CPU state is known as a context switch." - Hành động này của việc ghi lại trạng thái CPU được gọi là chuyển đổi ngữ cảnh.

Hướng Dẫn Shadowing Từng Bước

Để cải thiện khả năng nói tiếng Anh của bạn qua kỹ thuật shadowing, hãy làm theo các bước sau:

  1. Nghe và Hiểu: Bắt đầu bằng cách nghe video cẩn thận. Đặt mình vào ngữ cảnh của người nói và cố gắng hiểu các khái niệm chính được trình bày.
  2. Nghe Lại Nhiều Lần: Nghe lại từng câu từng đoạn của video. Điều này giúp bạn nắm bắt cách phát âm và ngữ điệu của người nói.
  3. Shadow Speak: Khi bạn nghe, hãy bắt chước theo cách mà người nói diễn đạt. Đừng ngần ngại dừng lại và lặp lại từng câu để đạt được phát âm tiếng Anh chuẩn.
  4. Ghi Âm Lại: Ghi âm giọng nói của bạn khi bạn thực hiện shadowing. Nghe lại để so sánh với giọng nói gốc, từ đó làm rõ những điểm cần cải thiện.
  5. Thực Hành Thường Xuyên: Để thành thạo shadowing tiếng Anh, hãy thực hành hàng ngày. Lợi ích của shadow speech là giúp bạn cải thiện không chỉ phát âm mà còn cả việc hiểu ngữ nghĩa và ngữ cảnh sử dụng từ.

Việc áp dụng phương pháp shadowing này sẽ giúp bạn nâng cao kỹ năng giao tiếp và phát âm tiếng Anh trong cuộc sống hàng ngày, tạo điều kiện thuận lợi cho việc tiếp nhận kiến thức từ các lĩnh vực khác nhau như khoa học máy tính.

Phương Pháp Shadowing Là Gì?

Shadowing là kỹ thuật học ngôn ngữ có cơ sở khoa học, ban đầu được phát triển cho chương trình đào tạo phiên dịch viên chuyên nghiệp và được phổ biến rộng rãi bởi nhà đa ngôn ngữ học Dr. Alexander Arguelles. Nguyên lý cốt lõi đơn giản nhưng cực kỳ hiệu quả: bạn nghe tiếng Anh của người bản xứ và lặp lại to ngay lập tức — như một "cái bóng" (shadow) đuổi theo người nói với độ trễ chỉ 1–2 giây. Khác với luyện ngữ pháp hay học từ vựng bị động, Shadowing buộc não bộ và cơ miệng phải đồng thời xử lý và tái tạo ngôn ngữ thực tế. Các nghiên cứu khoa học xác nhận phương pháp này cải thiện đáng kể phát âm, ngữ điệu, nhịp điệu, nối âm, kỹ năng nghe và độ lưu loát khi nói — đặc biệt hiệu quả cho người luyện IELTS Speaking và muốn giao tiếp tiếng Anh tự nhiên như người bản ngữ.