Why Linux Has This Syscall?!

Why Linux Has This Syscall?!

Tsoding

4 года назад

53,483 Просмотров

Ссылки и html тэги не поддерживаются


Комментарии:

@davidprock904
@davidprock904 - 16.07.2020 08:34

I'm working on my own OS on my own architecture, just realized what you said there is no difference about allocation of memory and a file. That is true with my system, also my system is IMPOSSIBLE to have a buffer overflow, and has a Physical switch, if its off, then no assembly / machine instructions can be changed or added... or removed, they can still run thow...but everything else can be modified... the perfect level of protection! Bring it on all you worms out there lol,, those couldn't run on my system anyway

Ответить
@marcosconceicao3223
@marcosconceicao3223 - 11.08.2020 00:41

Man, what a good content! Thank you!!!

Ответить
@oliverscott6421
@oliverscott6421 - 31.08.2020 10:21

How does your manpage search work?

Ответить
@sadcat520
@sadcat520 - 16.09.2020 21:05

This was a really good and informative videos but all the mouth sounds were so annoying...

Ответить
@menumenu287
@menumenu287 - 05.12.2020 03:52

great stuff, high quality, so much knowledge transfer... Thank you; hope you make more videos

Ответить
@leong4847
@leong4847 - 27.01.2021 15:46

I love this type of video! Definitely don't mind the lack of editing, it's great to see the full process

Ответить
@SekharPariga
@SekharPariga - 17.02.2021 12:03

does it possible to do the last example storing stripped hello world code using MALLOC?

Ответить
@ILoveSoImAlive
@ILoveSoImAlive - 27.03.2021 20:22

memory map is kind of a table, where system memory areas are "maped" into memory address range of a process. process doesnt have direct access to all the ram. only to the parts of the ram, which are mapped into his memory. the memory adress range of a process is virtual so to speak. sitting inside the sanbox.
so you can map any range of system memory into process memory. for example file buffer. so you can read the file inside your process. or you can map a memory range to 2 different processes and use this part of system memory as shared memory between 2 processes. or you can map range of system memory, which ist reserved for hardware buffer into process memory, then your process will be able to access this hardware directly.
btw, how do you think it was possible to have 2MB of system memory on a 8bit pc?
btw2, most of the system functions are writen based on basic input output system functions. its the first thing you learn, if you do something with assembler.

Ответить
@invokesus
@invokesus - 26.04.2021 03:00

wow amazing stuff! Learned a lot.

Ответить
@jokerpb4778
@jokerpb4778 - 26.04.2021 17:43

Amazing video thank you so much!

Ответить
@nigmar957
@nigmar957 - 26.06.2021 15:17

Спасибо за видео)

Ответить
@tatterdemalion898
@tatterdemalion898 - 18.08.2021 19:42

from byte -> kb -> mb -> gb etc. you multiply with 1024 not 1000 :D

Ответить
@josedejesuslopezdiaz
@josedejesuslopezdiaz - 22.09.2021 18:01

Your content is amazing! you have a new follower.

Ответить
@qerdcv
@qerdcv - 05.11.2021 12:04

Hello!
And welcome to another Tsoding session.
How about that?

Ответить
@gscacco
@gscacco - 15.01.2022 11:55

Great work !

Ответить
@MsDuketown
@MsDuketown - 16.01.2022 21:38

lol, yeah the world behind the compiler...

Ответить
@bradocksolo
@bradocksolo - 22.04.2022 17:53

Really good video! Thanks

Ответить
@totlajos587
@totlajos587 - 26.04.2022 02:36

What make great programmer is it IQ or something else?

Ответить
@bitshift264
@bitshift264 - 01.07.2022 21:26

Great stream! Thank you!

Ответить
@yuriykhodak6299
@yuriykhodak6299 - 02.10.2022 14:19

you are good, man

Ответить
@coffee-is-power
@coffee-is-power - 07.11.2022 22:30

tsoding is my favorite teacher!

Ответить
@tornikebuchukuri4114
@tornikebuchukuri4114 - 30.03.2023 23:40

im doing some os stuff rn and was struggling with mmap, this stream really helped

Ответить
@AlguienMas555
@AlguienMas555 - 02.05.2023 06:34

Awesome

Ответить
@ynchen
@ynchen - 10.09.2023 17:50

I absolutely enjoy this video!!

Ответить
@teenspirit1
@teenspirit1 - 17.11.2023 15:25

wow fat tsoding existed??

Ответить
@darkshadow5891
@darkshadow5891 - 25.11.2023 06:55

is this live stream is real. i dont thing so its real elon expretion not match with the voice.

Ответить
@vysakhanh7878
@vysakhanh7878 - 17.12.2023 14:52

thank you, learned a lot!

Ответить
@andrewlankford9634
@andrewlankford9634 - 31.12.2023 21:08

Software evolves to work with new hardware. Hardware evolves to make better software. Some hardware problems problems provoked software people to find workarounds for slow hardware.

Ответить
@andrewdunbar828
@andrewdunbar828 - 24.01.2024 13:07

Why questions are asked funny?

Ответить
@errelin1326
@errelin1326 - 26.01.2024 19:01

Probably few universities even teach these. This is AWESOME 🎉❤

Ответить
@sharpfang
@sharpfang - 07.02.2024 20:33

I'm baffled at this question. I'm not going to spend 2h to satisfy my curiosity why the author is surprised by mmap, but honestly the standard ways to access file look more suitable for some sort of tape memory where all the lseek calls rewind or fast forward the tape and read acts as play button. Mmap is a much more natural way to access files on a random access medium, you get the pointer to the first byte of the file and you can read, modify, move whatever you want wherever you want in any order just like you were operating on a mmalloc'd chunk of memory. Then you commit the changes and the file is what you wanted it to be. You can even mmap /proc/kmap as root and have unrestricted access to the entire RAM. Mmap is so easy, so convenient, so straightforward and obvious I'm completely stumped why anyone would ask 'why'.

Ответить
@mariuszdziem8203
@mariuszdziem8203 - 10.03.2024 15:29

Amazing shait ;) Great lecture professor!

Ответить
@WilliamRaezer
@WilliamRaezer - 30.03.2024 05:01

I think its cute when I forget that just as I am weak on graphics programming graphics programmers are weak on kernel programming.❤

Ответить
@rodsmade
@rodsmade - 03.04.2024 21:30

Hi, I'm writing my own implementation of malloc/realloc/free and this vod really helped getting into it. Thank you so much! Take care

Ответить
@michaelutech4786
@michaelutech4786 - 16.04.2024 10:10

"single purpose [..] go away" - That's a bit unfair. System calls are not application programming interfaces, they are the interface between the kernel and processes. The guiding principle for this kind of interface is to minimize the number of interactions between kernel and user space, because that interaction is expensive. Another guiding principle for this interface is to be stable, don't change, be as general as possible. You're supposed to use malloc, because that's designed to be an api and that's actually observing the single purpose principle (malloc(size) -> memory).

Ответить
@michaelutech4786
@michaelutech4786 - 16.04.2024 10:46

"This is probably why you shouldn't use mmap directly" - No. Mmap actually works on most if not all Unix-like systems and Windows has something close enough. The reason why you should not use mmap for memory allocation is because it the process of allocating memory from the kernel is probably more expensive than the task you are doing with that memory. Malloc works by allocating a big chunk of memory and then providing what you ask for. So f.e. you ask for 80 bytes, malloc allocates 1M and has enough memory to answer the next 50-1000 requests efficiently. Free is not necessarily returning memory to the system, it just marks it as usable for future malloc calls.

You want to use mmap in favor of using sbrk, because using sbrk will mess with the stdc-c library (or any runtime you might use). You want to use it in favor of using malloc if you have a long running task in need of memory that you either need to control (f.e. exec code) or in some other fringe use case where malloc doesn't work or is inefficient (which next to never happens, unless you're writing a jit compiler).

The problem with sbrk is that it increases the linear address space of the process. That was the only way how a process could get more memory in ancient UNIX. It's similar to what happens if you dynamically increase the memory of a virtual machine. Mmap solved this, by allowing a process to obtain access to memory outside of the linear address space that is assigned to a process at creation time. Sbrk is basically a DOS way of allocating memory ("extended" or "expanded" memory?).

Ответить
@ErikNorlander-go1zv
@ErikNorlander-go1zv - 20.04.2024 22:23

Great video!

Ответить
@prayer4675
@prayer4675 - 14.05.2024 20:48

Actually this syscall is not Linux only and originally it came from the BSD. So actually it will work at any today's BSD as well. At least I see it in the FreeBSD.

Ответить
@xaro6132
@xaro6132 - 16.05.2024 23:08

I was thinking when i saw the video, damn tscoding got rich and fat uwu. But i saw the video is 4 years old. Sorry for your loss

Ответить
@Iuigi_t
@Iuigi_t - 13.08.2024 12:51

Why is he no longer so rotund?

Ответить
@jony1710
@jony1710 - 17.08.2024 15:48

Pretty much nothing using morecore (a.k.a the sbrk syscall) on linux. I think plan9 still uses that approach. It's all mmap as far as I know these days.

Ответить
@rahantr1
@rahantr1 - 18.08.2024 23:48

mmap is a posix system call. It's not supposed to be user friendly. It's supposed to be an interface all posix compliant OSes provide as standard. Old and low level code can't be judged by SOLID principles or design patterns. Those are luxuries that system engineers don't have or need.

Ответить
@Turalcar
@Turalcar - 19.08.2024 04:21

mmap is versatile in the same way read and write are, i.e. perfectly fine

Ответить
@raykirushiroyshi2752
@raykirushiroyshi2752 - 23.09.2024 10:59

Wtf,how come you look now younger than in this video. Holly shit being fat is scary,here you looke 40+ while now yo barely look 30

Ответить
@SuperKritical
@SuperKritical - 01.10.2024 15:01

i was orgasming so hard when he was doing the binary thing, OMG !!!

Ответить