Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions 计算机系统笔记1 韦捷.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Synchronization

---- Intra : IPC

IPC :

- PA sends DATA to PB ( pipe() )
- PB wait ... from PA ( signal )
- PA race .. with PB : race condition



SPOOLING

---- on-line ( main frame)

- perahon
- Peripheral
- Multaneous



Critical Region

PA : --------------- critical region ( be careful ! ) -----------

Why ? ------- mutual and exclusive



Example 1 :

int lock = 0;

Thread a :

```c++
{
while(lock == 1){
** do nothing. just waiting. **
}
lock = 1;
** work region **
lock = 0;
}
```

Thread b :

```c++
{
while(lock == 1){
** do nothing. just waiting. **
}
lock = 1;
** work region **
lock = 0;
}
```



( share ) mutual :

- CLI ( clear / clean , I for interruption ) is an instruction.
- Busy wait
- Sleep / wake up



Requirements to avoid race conditions :

1. No two processes may be simultaneously inside their critical regions.
2. No assumptions may be made about speeds of the numbers of CPUs.
3. No process running outside its critical region may block other process.
4. No process should have to wait forever to enter its critical region.



---- Outline :

- CLI
- TSL / EXEC
- SW : strict ALT / peterson
89 changes: 89 additions & 0 deletions 计算机系统笔记2 韦捷.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
VFS

---- Challenges

---- Address-space($\ge$ 2.4)



Challenges :

---- Performance $\rightarrow$ Cache ( mem ) of disk$^{\prime}$s blocks ( address-space )

---- Adaptility. $\rightarrow$ diff. File system$^{\prime}$s format

---- Virtualization



Example : fd = open ( "/name/join/test.c", ... )

​ read (fd, ..., buf)



SAN

$\underline{NAS}...$ NFS

SMB



Task_struct fd = open ( "/..." )

​ fd = k



| Task_struct | | | | |
| ----------------: | ----------------: | -------------------------------------- | -------------------------------------------------- | ------------ |
| ...... | | | | |
| | | | | |
| $\longrightarrow$ | Files_struct | | | |
| | 0 : std::in | | | |
| | 1 : std::out | | | |
| | 2: std::err | | | |
| | $\longrightarrow$ | File_struct | | |
| | | ...... | | |
| | | cut_off $\longrightarrow$ ( f_dentry ) | dentry ( directory ) $\longrightarrow$ ( d_inode ) | Struct_inode |



mount/dev/vsbol/.../.../dir

| file system | vfs_mount | | |
| ----------- | ----------------- | ------------ | ------------------------- |
| | | | |
| | $\longrightarrow$ | ( /dev/... ) | $\longrightarrow$ ( ... ) |
| | | | |
| | | | |



---- History of Addr-space

Address-space ( $\ge$2.4 ) $\begin{cases} -- Buffer\;\;Cache\\ -- Page\;\;Cache\end{cases}$



| buffer | :(dev, blk#) | |
| ------ | ------------ | ------------ |
| | $\downarrow$ | $\downarrow$ |
| | driver | driver |
| | | |



Radix - free, Question : too large !

​ ( page table )

​ A : $\begin{cases} multi\underline{}level\;\;PT\\Internal\;\;PT \end{cases}$

1. Page : cache ( fd, offset )
2. Mmap (va, fd, offset, len) ---- mount



优先级搜索树!
67 changes: 67 additions & 0 deletions 计算机系统笔记3 韦捷.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
Hypervisor:

Hypervisor, also known as a virtual machine monitor (VMM), is a software or firmware layer that enables the virtualization of computer hardware. It allows multiple virtual machines (VMs) to run on a single physical machine, effectively dividing the resources of the host machine among the virtual machines.

two main types of hypervisors: Type 1 and Type 2.

1. Type 1 Hypervisor (Bare Metal Hypervisor):
- Type 1 hypervisors run directly on the host machine's hardware without the need for an underlying operating system.
- They provide better performance and higher levels of security compared to Type 2 hypervisors.
- Examples of Type 1 hypervisors include VMware ESXi, Microsoft Hyper-V, and Citrix XenServer.
2. Type 2 Hypervisor (Hosted Hypervisor):
- Type 2 hypervisors run on top of a host operating system.
- They rely on the host operating system for device driver support and other hardware-related functions.
- Type 2 hypervisors are typically used on desktop or laptop computers for personal virtualization.
- Examples of Type 2 hypervisors include VMware Workstation, Oracle VirtualBox, and Microsoft Virtual PC.

Hypervisors provide several key functionalities:

1. Virtualization: Hypervisors enable the creation and management of virtual machines. Each VM operates as a separate, isolated environment with its own virtual hardware, operating system, and applications.
2. Resource Allocation: Hypervisors allocate and manage physical hardware resources, such as CPU, memory, storage, and network bandwidth, among the virtual machines. This allows multiple VMs to share the underlying physical resources efficiently.
3. Isolation: Hypervisors ensure that each virtual machine is isolated from other VMs and the host system. This isolation prevents one VM from affecting the stability or performance of other VMs or the host.
4. Virtual Machine Management: Hypervisors provide tools and interfaces to manage virtual machines, such as creating, starting, stopping, pausing, and migrating VMs between physical hosts. They also allow for the allocation and adjustment of resources to meet the changing needs of the VMs.
5. Live Migration: Some advanced hypervisors support live migration, which allows a running VM to be moved from one physical host to another without disrupting its operation. This feature enables workload balancing, maintenance, and high availability.

Hypervisors have various use cases, including server consolidation, cloud computing, development and testing environments, desktop virtualization, and sandboxing applications. They provide a flexible and scalable solution for utilizing hardware resources efficiently and optimizing the deployment and management of virtualized environments.

Virtual Machine: type1(Xen) type2(VMware)



Instructions: privilege/sensitive instructions



Shadow Page table (SPT)

Shadow page table (SPT) is a technique used in virtualization to efficiently handle memory virtualization. It is primarily used by hypervisors to provide virtual memory isolation and address translation for virtual machines (VMs).

In a virtualized environment, each VM has its own virtual address space, and the guest operating system running within the VM assumes it has direct control over physical memory. However, in reality, the hypervisor abstracts the physical memory and maps the guest VM's virtual addresses to the actual physical addresses on the host machine.

how shadow page tables work:

1. Guest Page Tables: Each guest VM maintains its own set of page tables, known as guest page tables. These tables contain the mapping between the guest VM's virtual addresses and the guest physical addresses.
2. Shadow Page Tables: The hypervisor creates and maintains a separate set of page tables called shadow page tables. These shadow page tables mirror the structure of the guest page tables.
3. Address Translation: When a guest VM tries to access a memory location, the address translation process is performed. The guest virtual address is used to look up the corresponding entry in the guest page tables, providing the guest physical address.
4. Shadowing: The hypervisor intercepts and traps the memory access request made by the guest VM. It uses the guest physical address obtained from the guest page tables to index into the shadow page tables.
5. Shadow Page Table Updates: If the corresponding entry is present in the shadow page tables, the hypervisor uses the translated physical address from the shadow page tables to perform the memory access on the host machine. If the entry is not present, the hypervisor updates the shadow page tables accordingly.
6. Consistency and Synchronization: The shadow page tables must remain consistent with the guest page tables. Any modification or update to the guest page tables must be reflected in the shadow page tables. The hypervisor ensures this consistency by tracking and synchronizing changes between the two sets of page tables.

Using shadow page tables provides several benefits:

1. Efficient Address Translation: By using shadow page tables, the hypervisor can perform efficient address translation without having to modify the guest VM's page tables. This reduces the overhead of address translation and improves performance.
2. Memory Isolation: Shadow page tables allow for strict memory isolation between different VMs. Each VM operates within its own address space, and the hypervisor ensures that one VM cannot access or interfere with the memory of another VM.
3. Security and Protection: Shadow page tables enable the hypervisor to enforce memory protection mechanisms, such as read-only or no-execute permissions, for different memory regions of the guest VMs. This helps in preventing unauthorized access and enhancing system security.
4. Transparent Virtualization: The use of shadow page tables allows the guest VMs to operate unaware of the virtualization layer. The guest operating systems continue to use their own page table structures, while the hypervisor handles the translation behind the scenes.

Overall, shadow page tables are an essential component of virtualization technology, enabling efficient and secure memory virtualization in a virtualized environment.

Nested Page table(NPT)



- para-virtualization

- full-virtualization

- direct execution