Part of a larger series teaching programming. See codeschool.org
КОМЕНТАРІ: 188
@R3negade6383 роки тому
9 years later and this is the best resource on the topic. Really great.
@DragisaBoca10 років тому
Very well made, you made the world a better place.
@BlackM3sh6 років тому
At 31:50 you talk about environment variables. However there are some mistakes worth correcting for future viewers. First, although the environment variables are stored in the process' memory, it is stored as zero-terminated strings and not as one big string separated by new-line characters. It is also is not stored on the heap, nor is there a global variable in the data section pointing to it. The environment is actually stored entirely on the stack and is a part of the initial process stack that is set up before the program starts running. The first value on the stack is the argument count followed by an array of the addresses of the different arguments, then address 0 marking the end of the argument array. Right after that there is a second array of addresses which each point to a zero-terminated string which would be the environment variables, this array is also terminated by having address 0 at the end. There is actually a third array of auxiliary vectors but after that there is an unspecified amount of bytes before the information block starts. It's generally inside this block the command line arguments and environment variables are stored, as in the actual string values. You can confirm this by dumping the stack of pretty much any program and you typically find all the environment variables at the very end (highest memory address). If you are on Linux you can do this by first reading the '/proc//maps' file for any process, just replace with that process' PID. This file contains the ranges of memory mapped to the process and what they are mapped to. Near the bottom you'll see one line with the range mapped to [stack]. Take note of the start address and calculate how big it is in bytes. Then run 'sudo xxd -s -l /dev//mem', example 'sudo xxd -s 0x7fff182bd000 -l 0x22000 /dev/14950/mem'. And the environment variables should get printed out together with their hex values and address location. To illustrate this further I've written a small c program that prints all the environment variables using the argv array pointer. As you can see the environment variable pointers are stored pretty much right after argv. #include int main(int argc, char **argv) { for (int i = argc + 2; argv[i] != NULL; i++) { printf("%s ", argv[i]); } return 0; } You can of course make it less stupid by using the full version of main which includes a pointer to the first element in the environment pointer array. #include int main(int argc, char **argv, char **envp) { for (int i = 0; envp[i] != NULL; i++) { printf("%s ", envp[i]); } return 0; } This is all defined as a part of the ABI (application binary interface) for both the x86 and x86_64 architecture, so 32 and 64 bit desktop computers. tl;dr: The environment is not a single long string separated by new-line characters. The environment variables and the pointers to them are both stored on the stack or just before it.
@TheNullBox5 років тому
Wow man! Thank you :) Both the video and your comment. Amazing stuff!
@payloadartist3 роки тому
Thanks. This comment should be pinned!
@crptc57073 роки тому
Thank you sir just tried your code in online c ide and it runs exactly as you described, but other than than video is great!
@sangramjitchakraborty78453 роки тому
Incredibly informative. Thank you for commenting this.
@leaharrington44723 роки тому
While not part of the kernel ABI, as you point out, glibc provides a global variable (char ** environ) pointing to the environment, and may relocate the environment to the heap in setenv() as needed.
@sodapopinski99224 роки тому
so many levels of abstraction,by the time people are clicking on their GUI's it is a symphony of perfect timed and executed processes, but listening to this I can really imagine year after year problems develop and more complicated solutions come into play stepping up a level of abstraction, I mean 60 years is so impressive to see how for we come, from logic gates, MOSFETS to EEPROMS to insane clock speeds to RISC to now but it all started at a level of someone feeding an electronic impulse into a JK FLIP FLOP and trapping that high or low impulse.... it is truly baffling!!!!
@automatenmark505121 день тому
it's mind blowing but also magical to see how all comes down to some tiny switches
@leonbishop74043 роки тому
2:00 kinda sus abbreviation you got there
@eshgholah10 років тому
I have loved every second of your videos. Specially the Unix system call series. Could you please kindly do an advanced series of Linux Internals. I know it is too much to ask but obviously you are the right person to do it. I have never seen anyone else describing things so clear and nicely. Thanks a million.
@Synchr0nix6 років тому
I've been watching this video series every day, for the last 3 days, and I learn a little more from it each time, lol. Thanks man. This is one of the most professional lessons I've ever found on UKposts. I can tell you know what you're talking about.
@penisafotza48073 роки тому
1:46 Oh God! I cant get away from it...
@rzathamesmer9 років тому
More Unix videos please! You're an excellent teacher, and the slides are very well done. :))))))))
@ben22583 роки тому
I just discovered your channel and can't stop watching your videos! They're incredibly helpful and clear. Just wanted to say it seems to me this and the next video should be added to your Operating Systems playlist.
@pouryamehdinejad81244 роки тому
The best explanation of system calls I could find on the internet. Thanks to Brian Will
@AdamOutler8 років тому
This is a very informative Linux/Unix System Calls series.
@JoePhilipps8 років тому
Applications are ever more security aware, and one caveat with malloc(3) and mmap(2) is to determine what is sensitive in what has been allocated (e.g., storage for passphrases, cached encryption keys, etc.), and that should be zeroed before calls to free(3) or munmap(2). There may be no guarantee by the OS that newly malloc'ed or mmapped regions have been thus scrubbed, so it's up to the process, as best as it can, to sanitize such regions before handing them back.
@AdamOutler8 років тому
***** seems like there should be a system call to handle sensitive data. I wonder if it would be possible to somehow fill the memory with memory requests to just scan for random strings. In what context, though, do you mean apps are more security aware? Are you speaking of just this?
@JoePhilipps8 років тому
One should always consult the manual page for the system call you want to use, and about the system for which you wish to program. This guy obviously had to remain generic to cover SysV, Linux, *BSD, OS X, etc., but each system can have other restrictions or features. For example, if you want to write a utility for an SELinux system, you will have contexts to deal with, and such things operate additionally in system calls (e.g., I think child processes after a fork(2) also inherit SELinux contexts).
@JoePhilipps8 років тому
_I wonder if it would be possible to somehow fill the memory with memory requests to just scan for random strings. In what context, though, do you mean apps are more security aware?_ Exactly that, Adam Outler . I just wanted people to start thinking more securely if they want to program at the system call level. It's worth a look at a particular OS's manpages or equivalent to see if such conditions are specified, such as [s]brk(2) (upon which malloc(3) is based) zeroing memory pages before they're returned to the process. In fact, because a process can be killed at any time, it is wise in more security minded apps to scrub storage (whether variables/RAM or parts of files) as soon as they're not needed. To a certain extent, you can control this by locking the pages into RAM if you have enough priviledge to the process, so that such RAM will never be written to the swap partition. That represents another potential security threat, the superuser (or anyone with enough access to the underlying device node) sifting through the swap space for such nuggets.
@nikkehtine2 роки тому
High quality presentation and commentary. We get such a long, interesting and informative video for the great low price of free. Thank you so much.
@kshahkshah8 років тому
This is a truly excellent, informative and well laid out video. Thank you so much. I've been coding for 15+ years and got a lot out of this, especially having mostly dealt in interpreted dynamic languages and not having to ever manage memory myself
@crptc57073 роки тому
It's a fantastic tutorial! I've been baffled with kernel space and user space for quite a long time and misunderstood that system call incurs context switch between user process and kernel process, until I watched this video... million thanks!
@mbigras5 років тому
I’ve searched for a video like yours for a long time, thank you so much for this work!
@greymind00723 роки тому
Thanks for making this gem of a video. Your content is lucid and enriching at the same time
@fouzaialaa79623 роки тому
i studied this in my engineering class and it took them almost 4 months to teach us this ...this 45 minute lecture made it so easy and simple !!! in uni they stretched it so much that you forget about it start questioning everything again every lecture thx for the upload
@arrikd83583 роки тому
what Uni?
@fouzaialaa79623 роки тому
@@arrikd8358 ESPRIT in tunisia
@WeightlessFlex3 роки тому
Using this to study up for my interview as a production engineer. Best videos resource I’ve found besides certain books. Thank you. Maybe can you come up with a practice problem series?
@tigeruppercut79 років тому
One of the most solid videos I've seen on Linux. Great job. Thanks.
@stefanvoicu64842 роки тому
I have a class on Operating Systems and this has been very helpful! thank you
@amarnathp45603 роки тому
I am seeing this after 9 years. Nice content
@Occcc127 років тому
What an excellent and clear explanation. thanks a lot for the upload!
@cyrilemeka69872 місяці тому
Very informative. I needed this to better understand low level details for the program I am currently writing in C++ and llvm. Thanks
@JethroYSCao4 роки тому
When I first learned about permissions on directories, it was said that 'x' allows one to cd into it, even if that might not be the most precise explanation, I think it's a good enough proxy to give users the intuition.
@00chiuppi11 років тому
BIll - great work here. very helpful for me in understanding issues I'm dealing with on some servers at work. thanks
@patrickmullen2914Рік тому
Thank you for taking the time to make this video. A thumbs up 👍 I'll be viewing more of your videos 🙂 including part 2 of this one
@jjpcondor11 років тому
Fine job, Brian!
@landro35524 роки тому
0:00 ~ UNIX-like systems 1:46 ~ UNIX standards 2:57 ~ System calls 5:21 ~ Process states
@waiwinglam85417 років тому
This is a very quality tutorial. Thanks a lot!
@TheDerHeld6 років тому
great content with awesome sidenotes to give you the big picture - thank you!
@PauloConstantino1673 роки тому
Your content is Gold. Sad to see you inactive........
@briantwill11 років тому
I'm no expert issue on this issue, but my investigation at the time concluded that brk/sbrk are actually archaic, as the concept of a data segment barrier is outmoded in paged-memory environments. Yes, mapping /dev/mem is not the way to go, but mmap in modern Unixes can do 'annonymous mapping,' which maps to swap-backed memory pages rather than any file. The Wikipedia entry on mmap mentions this. I believe this is what most allocation routines use today, not brk/sbrk.
@Yazan_MajdalawiРік тому
Wow, where have you been, this is a treasure!
@Jonathan-od5xc4 роки тому
This is incredible, thank you.
@lanhsunsiingh48985 років тому
Great Work Brian!
@aborkar4 роки тому
Sir, you may be the reason I get my dream job
@srenh-p37989 місяців тому
Great video Brian
@fuanka17246 років тому
Excellent explanation, thank you!
@manojambakkat12 років тому
Thanks a ton. This is very nice video on system calls and process address space.
@GideonMaina3 роки тому
Great content, thanks for sharing the knowledge.
@ravisaraswat24526 років тому
you are the real Guru, thanks a lot , really appreciate your help and videos. :)
@gavalinilesh8018610 років тому
Thank you Brian.
@microto8 років тому
awesome! keep up the good work
@0xrgg9655 років тому
laughed at "we have a process that is forking itself"
@rangapavankurapati25572 роки тому
Thank you Sir. Great explained.
@ChandraSekhar-ur1so7 років тому
Thanks a lot for the video.
@XavierMJames4 роки тому
Wow ! that's one helpful easy to understand lecture on UKposts
@shaunmorgan22026 років тому
Good video, just a small point. Linux is a kernel, Debian and others are the Unix derivatives that use the Linux kernel.
@rajusakthitube6 років тому
Thank you so much Brain. very useful video.
@Stakkato9811 років тому
good work, very straight forward.
@Larock-wu1uu2 роки тому
This is amazing!
@DaLakersFan245 років тому
GREAT VIDEO, THANKS FOR MAKING THIS
@emnabenayed999510 років тому
Thank you!
@briantwill11 років тому
Yeah, I should have phrased this better. To my understanding, user groups were created solely with actual groupings of humans in mind, a use case of diminished importance today in most settings.
@bob-ny6kn3 роки тому
The depth of the information you cover is what scared me away from Computer Science. I call myself a programmer, but obviously I am more a Code Groupie. Your video is very nice, and still relevant so many years after it was made. I wonder if ever architecture will significantly change?
@EmilFihlman8 років тому
Great video!
@jeffcauhape81106 років тому
Well done!
@yurigansmith9 місяців тому
Thanks for this insightful playlist. Btw: Can you recommend a good book (or lecture notes) on this topic?
@mehdikerdoud613911 місяців тому
thank you so much for thee great explanation
@kami-brawlstars96353 роки тому
System call: Generate luminous element! Discharge!
@zaggernut50543 роки тому
i gEt tHaT RefeREnCe
@sangramjitchakraborty78453 роки тому
While watching SAO i kept thinking how insecure the system was.
@Feninou3 роки тому
Good job man !
@aquapurity7 років тому
An amazingly helpful video on the subject. Thank you very much.
@GrubenM6 років тому
Yep, this is excellent
@valdasadomaitis7199 років тому
Came here through codeschool.org while googling for a system call and i'm really enjoying the rest of the content.
@uboxer11 років тому
excellent job, thanks.
@m3hdim3hdi4 роки тому
Thank you so much you helped me a lot
@vishals93535 років тому
It is an excellent video which covers hell lot of things with great clarity in a short time.Thanks for the tutorial.
@krux027 років тому
I just watched it and I have to say I really liked the information it had. But you should know that in the area of Super Computers, you still have a lot of users logging in to the same system. And super computers are mostly run by unix system and are not likely to die out in the forseeable future.
@sergioropo30195 років тому
Fantastic!
@Crux16111 років тому
However, I should say that the captions seem to work exceptionally well. :D
@chandanrock48024 роки тому
Hello Sir, thank you for your knowledge, all the videos are really great and understandable, Sir I wanted to know name of the book from where I can get this information, thank you
@pauljtomas5 років тому
Great stuff - thank you
@yesterdaysguy11 років тому
Actually it's Berkeley SOFTWARE Distribution. -Nice first pic though gotta love Jurassic Park.
@ooo000ps84 роки тому
great video, Thank you very much
@MaxCoplan5 років тому
It says this is one part of a larger series. What is the larger series?
@NeelSandellISAWESOME2 роки тому
BSD actually stands for Berkley Software Distribution
@jamebozo11 років тому
good lecture, thank you very much :)
@jonasfelix77004 роки тому
How does this compare to modern Windows Systems? Would be interesting to see a comparison video.
@Crux16111 років тому
this is great, and i'm all for the smaller chunks however, I feel this video has some volume normalization issues.. That could be something to double check before creating your final version. :D Still Very Awesome
@ranjirhodes3 роки тому
Excellent info , though i had to reduce to 0.75x speed . Thank you for the explanation 👍 can u give info on relation between smaps and mmap and about virtual memory and resident set size
@tochukwunwoko56324 роки тому
Great Video
@MichaelDCBowen12 років тому
what is your presentation app? these slides are perfect.
@-XArchLinuxEnjoyerX-5 років тому
Where is the larger series? I'd like to watch it! Thanks
@mohammadalhyari42724 роки тому
seems the site is down ?
@slogslogger89219 років тому
Love it
@Aemilindore3 роки тому
you are crazy good!
@alexanderher76927 років тому
I swear, Im gonna ace this course (OS) without attending it:D
@shashank889 років тому
Thank you ! crisp and to the point!
@samarthtandale9121Рік тому
This is a superb playlist! Though this is 11 yrs old, can you please tell where can I find the subsequent videos cauz the link provided in description is out-dated i think ... Please tell where can I get the subsequent videos of this series or upload them in the same playlist on youtube. This is a very kind request of mine ... Thank You though for whatever you have put on the channel for free !!!
@ko953 роки тому
So a system call is some service that the operating system makes available from hardware and application/processes use these services to function...?
@pdr06633 роки тому
Brian, I’m learning to program on Research Unix V6 in C, so I love your tutorial. I have a small nitpick. Plurals of nouns which end in “s” are pronounced “es” like any other noun ending, unlike (I think) the only exception, which is those which end in “x” which have a different ending containing the pronounciation you are using. Seems to be a recent US thing, and particularly in IT. Love the tutorials, thanks!
@impaque6 років тому
Thanks!
@subee1282 місяці тому
Thank you very much
@JosefdeJoanelli3 роки тому
Unix system calls casually explained
@goldibollocks2 роки тому
The init process be like "I just wanna fork"
@Alex2Buzz6 років тому
Technically, mmap maps memory at a specified address, while malloc finds free address space and allocates there. Of course, you know this, but I'll just note the correct usage in the comments.
@crateim6 років тому
mmap is how a userspace program requests memory from the kernel (with an anonymous mapping, and it can, but does not have to specify the address it gets mapped at, it can leave it up to the kernel to choose). `malloc` is not a system call, but a libc function that will use `mmap` under the hood.
@Alex2Buzz6 років тому
Aaron Miller malloc can be implemented using an anonymous mmap, but it can also be implemented with sbrk. I do see your point, but simplifying mmap as just “the memory allocator” is a bit of a misrepresentation.
@GarrickHe6 років тому
I thought malloc uses sbrk() or was is mmap a recent change? Thanks.
@crateim6 років тому
Garrick He depends on your libc/malloc, recent ones mostly mmap I believe, but when in doubt strace and find out :)
@llama191713 років тому
Just stating the obvious, 90% of why i'm watching this particular video on the plane is "speaker's voice does not make me ashamed to be an engineer", good job