Skip to content

Commit ac2c96f

Browse files
committed
note update
- os
1 parent fe9da24 commit ac2c96f

File tree

6 files changed

+28
-20
lines changed

6 files changed

+28
-20
lines changed

content/OS/CPU/CPU Cache.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,24 @@ Author Profile:
66
tags:
77
- OS
88
Creation Date: 2023-07-14T20:41:40+08:00
9-
Last Date: 2024-01-11T23:21:39+08:00
9+
Last Date: 2024-03-18T19:04:56+08:00
1010
References:
1111
---
1212
## Abstract
1313
---
14-
- A *small-sized* type of volatile computer memory that provides *high-speed data access* to a [[CPU]]
14+
- A **small-sized** type of volatile computer memory that provides **high-speed data access** to a [[CPU]]. **10-100 times faster** than accessing accessing data from [[Main Memory]]
1515

16+
## Cache Locality
17+
---
18+
![[cache_locality.gif]]
19+
- Also known as **Locality of Reference**
20+
- [[#Cache Line]] is transferred into [[CPU Cache]] when we obtain [[Instruction]] or [[Data]] from [[Main Memory]]
21+
- If we are retrieving the same data or surrounding data. For the [[CPU]], instead of going to Main Memory to retrieve. It can obtain directly from the CPU Cache which is much faster (**10-100 times faster**)
22+
</br>
23+
24+
- This contributes greatly to performance since [[Process (进程)]] usually only accesses a small portion of the [[Memory Address]] space within a small time interval
1625

1726

18-
## Terminologies
19-
---
2027
### Cache Line
2128
* Ranging from 32 to 128 [[Computer Data Representation#Byte]]
2229
* When the CPU fetches data into the cache, it brings in entire cache lines rather than individual bytes
@@ -29,10 +36,3 @@ References:
2936
- When the [[CPU]] requests data that is not found in the [[CPU Cache]]
3037
- It requires fetching the data from the slower [[Main Memory]], incurring a higher access time compared to a [[#Cache Hit]]
3138

32-
### Cache Locality
33-
- Also known as *Locality of Reference*
34-
- [[#Cache Line]] is transferred into [[CPU Cache]] when we obtain [[Instruction]] or [[Data]] from [[Main Memory]]
35-
- If we are retrieving the same data or surrounding data. For the [[CPU]], it instead of going to Main Memory to retrieve. We can obtain directly from the [[CPU Cache]] which is much faster
36-
</br>
37-
38-
- [[Process (进程)]] accesses only a small portion of the [[Memory Address]] space within a small time interval
2.42 MB
Loading

content/OS/Memory/Memory Safety.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tags:
99
- java
1010
- cpp
1111
Creation Date: 2024-01-13, 21:20
12-
Last Date: 2024-01-22T15:45:33+08:00
12+
Last Date: 2024-03-18T11:47:06+08:00
1313
References:
1414
draft:
1515
---
@@ -24,10 +24,9 @@ draft:
2424
</br>
2525

2626
### Poor Memory Safety
27-
- [[Segmentation Fault]]
28-
- Malicious input to trick the program from doing unwanted things. [70% of reported security vulnerabilities](https://msrc.microsoft.com/blog/2019/07/a-proactive-approach-to-more-secure-code/) in low-level systems are caused by memory corruption. [Memory Safe Languages in Android 13 reduces vulnerabilities](https://security.googleblog.com/2022/12/memory-safe-languages-in-android-13.html)
29-
- Backdoor that some hackers are taking advantages of
30-
- And many other [memory errors](https://en.wikipedia.org/wiki/Memory_safety#Types_of_memory_errors)
27+
- [[Segmentation Fault]] that leads to a crash in the [[Process (进程)]] or **write into other parts of the process**
28+
- When hackers can write into other parts of the process, they can use malicious input to trick the program from doing unwanted things. [70% of reported security vulnerabilities](https://msrc.microsoft.com/blog/2019/07/a-proactive-approach-to-more-secure-code/) in low-level systems are caused by memory corruption. [Memory Safe Languages in Android 13 reduces vulnerabilities](https://security.googleblog.com/2022/12/memory-safe-languages-in-android-13.html)
29+
- Backdoor that some hackers are taking advantages of, and many other [memory errors](https://en.wikipedia.org/wiki/Memory_safety#Types_of_memory_errors)
3130

3231
### Achieve Memory Safety
3332
**Rust**

content/OS/Synchronization/Concurrency (并发).md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ Author:
33
- Xinyang YU
44
Author Profile:
55
- https://linkedin.com/in/xinyang-yu
6-
tags:
6+
tags:
7+
- OS
78
Creation Date: 2024-02-22, 17:53
89
Last Date: 2024-02-22T18:10:51+08:00
910
References:

content/Programming/Pointer.md

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,24 @@ tags:
88
- rust
99
- c
1010
- java
11+
- go
1112
Creation Date: 2024-01-04, 14:55
12-
Last Date: 2024-03-17T18:36:02+08:00
13+
Last Date: 2024-03-18T19:30:12+08:00
1314
References:
1415
draft:
1516
---
1617
## Abstract
1718
---
18-
- A variable whose value is [[Memory Address]]
19+
- A [[Datatype]] whose value is [[Memory Address]], and itself is located at a memory address too
20+
- In the diagram below shows some [[Go]] codes, we create a pointer `var p *int32` and perform [[#Pointer Dereference]] with `*p`
21+
![[pointer_example.png|600]]
1922

23+
>[!bigbrain] Pass data by pointer
24+
> Pass data to functions by pointer is **memory-efficient**. The data we pass into a function is basically a [[Memory Address]] to access that block of data. If we pass data into functions without pointer. We need to create an entire duplicate of data and pass it to the functions.
25+
>
26+
> In [[Java]], data is passed to functions by pointer by default. However in [[Go]], we need to explicity specify the pointer datatype for the function input, then we can pass data by point!
2027
### Pointee
21-
- The **actual data** that a pointer points-to inside the [[Address Space#Heap Segment]]
28+
- The **actual data** that a [[Pointer]] points-to inside the [[Address Space#Heap Segment]]
2229

2330
### Pointer Dereference
2431
- The process of accessing [[#Pointee]] of a [[Pointer]]
@@ -29,6 +36,7 @@ draft:
2936
- [[Pointer]] that doesn't point to any memory location, basically contains a invalid [[Memory Address]]
3037
- In [[C]], it is represented by `0` or `nullptr`
3138
- In [[Java]], it is represented by `null`, [[Datatype#Custom Datatype]] can be `null`
39+
- In [[Go]], it is represented with `nil`
3240

3341
## Void Pointer
3442
---
915 KB
Loading

0 commit comments

Comments
 (0)