Zig Master: Process Virtual Address Space

  Рет қаралды 1,320

Dude the Builder

Dude the Builder

Күн бұрын

Пікірлер: 14
@devbites77
@devbites77 3 ай бұрын
Great visualizations make it so easy to understand.
@michaelscofield4524
@michaelscofield4524 5 ай бұрын
This and your past series are by far some of the best Zig and general programming content on the internet, really learned a lot by watching. Keep it up!
@deadmarshal
@deadmarshal Ай бұрын
Hey. Please consider making a video on multi-dimensional arrays and slices and different methods of passing them to functions as I'm having difficulty understanding these. Thanks a lot!
@dudethebuilder
@dudethebuilder Ай бұрын
Great idea! I'll put it on schedule for upcoming videos.
@thilina91
@thilina91 2 ай бұрын
thanks for the video!! great stuff!
@joaquimpedro4984
@joaquimpedro4984 7 күн бұрын
I have a doubt, if we try to allocate a constant u32 (4bytes) in the heap it also create a u32in the statict block, or just a u8 (it only stores the address of the heap). This question makes sense or just reveal that i don't understood nothing!
@dudethebuilder
@dudethebuilder 7 күн бұрын
You're right, that question is very valid and goes to the core of how Zig handles allocations. The allocation is in the heap area of memory but the actual pointer you get back is either in the static (const) or stack (var) area. The pointer is the size of a usize, i.e. 8 bytes in 64 bit systems.
@zomaarwat9
@zomaarwat9 5 ай бұрын
If the const in the function gets stored in static memory will it outlive its scope or does something invalidate it after the function ends?
@dudethebuilder
@dudethebuilder 5 ай бұрын
Great question. It will outlive the scope of the function. In the next video, I'll show some code demonstrating this.
@joaquimpedro4984
@joaquimpedro4984 Ай бұрын
If it lives in the static block, all the other functions will have access to it?
@fizzbuzz4820
@fizzbuzz4820 5 ай бұрын
Since const values are pretty far away from the stack frame, doesn't it affect execution time due to weaker data locality?
@dudethebuilder
@dudethebuilder 5 ай бұрын
I think that could happen if we were dealing with large amounts of data where reading a contiguous chunk into a cache line is desired. But usually, function parameters are small enough to place into CPU registers directly, and Zig also performs what it calls Parameter Reference Optimization (PRO) that automatically determines whether it's more efficient to pass a const pointer to large data instead of copying the data itself. In this case too the pointer would fit in a register.
@andreffrosa
@andreffrosa 5 ай бұрын
What about const parameters?
@dudethebuilder
@dudethebuilder 5 ай бұрын
In Zig, function parameters are always const, but they're still allocated in the function's stack frame; probably since they have different values in each call. But to actually mutate a value passed to a function, you have to pass a pointer to it in Zig.
Zig Master: Memory in Practice
20:45
Dude the Builder
Рет қаралды 1,2 М.
Zig Master: Slices
25:25
Dude the Builder
Рет қаралды 1 М.
Triple kill😹
00:18
GG Animation
Рет қаралды 16 МЛН
Players vs Pitch 🤯
00:26
LE FOOT EN VIDÉO
Рет қаралды 14 МЛН
Crafting executables from raw bytes
26:43
Kay Lack
Рет қаралды 31 М.
What's a Memory Allocator Anyway? - Benjamin Feng
48:30
Zig SHOWTIME
Рет қаралды 56 М.
Zig in Depth: Memory Management
36:10
Dude the Builder
Рет қаралды 7 М.
Why More People Dont Use Linux
18:51
ThePrimeTime
Рет қаралды 300 М.
But, what is Virtual Memory?
20:11
Tech With Nikola
Рет қаралды 300 М.
What P vs NP is actually about
17:58
Polylog
Рет қаралды 121 М.
The Only Unbreakable Law
53:25
Molly Rocket
Рет қаралды 335 М.
Zig Master: Single Item Pointer
18:02
Dude the Builder
Рет қаралды 775
When you Accidentally Compromise every CPU on Earth
15:59
Daniel Boctor
Рет қаралды 871 М.