Комментарии:
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
ОтветитьMan, what a good content! Thank you!!!
ОтветитьHow does your manpage search work?
ОтветитьThis was a really good and informative videos but all the mouth sounds were so annoying...
Ответитьgreat stuff, high quality, so much knowledge transfer... Thank you; hope you make more videos
ОтветитьI love this type of video! Definitely don't mind the lack of editing, it's great to see the full process
Ответитьdoes it possible to do the last example storing stripped hello world code using MALLOC?
Ответить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.
wow amazing stuff! Learned a lot.
ОтветитьAmazing video thank you so much!
ОтветитьСпасибо за видео)
Ответитьfrom byte -> kb -> mb -> gb etc. you multiply with 1024 not 1000 :D
ОтветитьYour content is amazing! you have a new follower.
ОтветитьHello!
And welcome to another Tsoding session.
How about that?
Great work !
Ответитьlol, yeah the world behind the compiler...
ОтветитьReally good video! Thanks
ОтветитьWhat make great programmer is it IQ or something else?
ОтветитьGreat stream! Thank you!
Ответитьyou are good, man
Ответитьtsoding is my favorite teacher!
Ответитьim doing some os stuff rn and was struggling with mmap, this stream really helped
ОтветитьAwesome
ОтветитьI absolutely enjoy this video!!
Ответитьwow fat tsoding existed??
Ответитьis this live stream is real. i dont thing so its real elon expretion not match with the voice.
Ответитьthank you, learned a lot!
Ответить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.
ОтветитьWhy questions are asked funny?
ОтветитьProbably few universities even teach these. This is AWESOME 🎉❤
Ответить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'.
ОтветитьAmazing shait ;) Great lecture professor!
ОтветитьI think its cute when I forget that just as I am weak on graphics programming graphics programmers are weak on kernel programming.❤
Ответить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
Ответить"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).
Ответить"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?).
Great video!
Ответить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.
Ответить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
ОтветитьWhy is he no longer so rotund?
Ответить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.
Ответить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.
Ответитьmmap is versatile in the same way read and write are, i.e. perfectly fine
Ответить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
Ответитьi was orgasming so hard when he was doing the binary thing, OMG !!!
Ответить