Unix system calls (2/2)

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ก.พ. 2025

ความคิดเห็น • 92

  • @W1Wyrm
    @W1Wyrm 4 ปีที่แล้ว +81

    Thanks! Almost 10 years later still completely relevant and cover a lot of ground.

    • @Kabodanki
      @Kabodanki 4 ปีที่แล้ว +3

      there's no use for the base of syscall to change

    • @lawrencemanning
      @lawrencemanning 3 ปีที่แล้ว +9

      @@Kabodanki Yup we'll be stuck with this 1970s Unix forever....

    • @JosephRawsonWorks
      @JosephRawsonWorks 2 ปีที่แล้ว

      Bloody fofum buffer overflow

  • @louis9116
    @louis9116 2 ปีที่แล้ว +25

    came to learn about syscalls, but this man just summed up my entire OS course. Cannot thank you enough

  • @rweaver6
    @rweaver6 7 ปีที่แล้ว +57

    High quality tutorial. No fumbling for words, moves along efficiently and covers the architectural fundamentals.

  • @ThunderAppeal
    @ThunderAppeal 5 ปีที่แล้ว +21

    This guy is brilliant.
    So refreshing to hear this explained without some foreign accent by someone who knows exactly what they are talking about.

  • @godnyx117
    @godnyx117 ปีที่แล้ว +3

    I have no words! Wherever you are, I hope that you are doing great!

  • @photoallergic
    @photoallergic 8 ปีที่แล้ว +7

    Aw man, thanks so much for these videos. I'm a teaching ass. for HPC at uni and I know all this stuff, but having it read aloud and so well explained puts me in soothing, precious slumber with a peaceful smile. "Yes ... yes, that's how block devices work ..."

  • @takshpatel8109
    @takshpatel8109 2 ปีที่แล้ว +1

    One of the best Linux explainer 🌟🌟🌟

  • @berlin-unlocked
    @berlin-unlocked ปีที่แล้ว +2

    Super great video! Good for preparation for interviews)) in 47:47, in SISEGV, I think that "V" means "violation"

  • @mikaelohlin6869
    @mikaelohlin6869 4 ปีที่แล้ว +3

    Partition 0 is where the formatting pattern is stored, so the first readable partition lies on top of that layer. That is also why the disk isn't as big as the producer tells you because it takes some bytes each slice that gets marked.

  • @rancidbeef582
    @rancidbeef582 3 ปีที่แล้ว +7

    Just to be pedantic, you can link() the same file to two different filenames even in the same directory. For example, on an old Unix System V machine I used to use where disk space was at a premium, the /bin/cp, /bin/mv, and /bin/ln programs were all linked to the same actual file, since those operations have a lot in common. When run, the program will check argv[0] (i.e. the file name of the program), to figure out which operation to perform. Pretty sneaky!

    • @johnnybravo2342
      @johnnybravo2342 2 ปีที่แล้ว +5

      busybox uses the same metod i think :)

    • @godnyx117
      @godnyx117 ปีที่แล้ว +1

      That's actually very smart, even in modern systems. Like mentioned, Busybox does it and I plan to do the same in the future when create these programs in my language.

  • @MrAeQwa
    @MrAeQwa 2 หลายเดือนก่อน

    Great, concise and understandable explanations!

  • @Danscottmusic
    @Danscottmusic 9 ปีที่แล้ว +10

    Thanks, these videos have covered a lot that I wasn't understanding!

  • @Locane256
    @Locane256 8 ปีที่แล้ว +2

    These videos really helped me round out my understanding of Unix basics. I would have been a lot more lost without being taught some basics first - these videos really helped solidify knowledge I had that was fragmented... created an inode table to map to a larger directory structure, if you will ;)

  • @МаксПреображенский-ы3у
    @МаксПреображенский-ы3у 7 ปีที่แล้ว +12

    If someone wondering about real syscalls signatures, not just python-like pseudo-code, you can always type "man 2 " into your shell and get the answer.

  • @esantix
    @esantix 8 หลายเดือนก่อน

    On min 33:15: what does it mean there's a buffer for each block? All storage is "repeated" on disk and the buffer?

  • @impaque
    @impaque 7 ปีที่แล้ว +1

    Thank you very much for these series, they're very informative and very well presented.

  •  8 ปีที่แล้ว +9

    thanks for this, far the most useful video on the topic!

  • @Mr.Nichan
    @Mr.Nichan 2 ปีที่แล้ว

    39:04 I believe that's spelled "SCSI device", for "Small Computer System Interface device" (not, for instance, "scuzzy device", using "scuzzy", a 1960s coinage for "dirty", "grimy", "disreputable", or "sleazy").

  • @abdulmoizsheikh8031
    @abdulmoizsheikh8031 4 ปีที่แล้ว +3

    4:25
    Can someone please explain why a write() call is not guaranteed? I just checked the man pages for write and it clearly says that on a successful write call, the number of written bytes is returned. Have I missed something here?

    • @easilyexplained-inenglishh9491
      @easilyexplained-inenglishh9491 4 ปีที่แล้ว +2

      Hi Abdul!
      I had the same question, and found this in the man page for 'write', under 'NOTES':
      A successful return from write() does not make any guarantee that data has been committed to disk. On some filesystems, including NFS, it does not even guarantee that space has successfully been reserved for the data. In this case, some errors might be delayed until a future write(2), fsync(2), or even close(2). The only way to be sure is to call fsync(2) after you are done writing all your data.

  • @dixztube
    @dixztube ปีที่แล้ว

    Learned a lot here. Thanks!!

  • @PIX_BMS
    @PIX_BMS ปีที่แล้ว

    I wish I'd found these videos 12 years ago.

  • @jacksonfive5180
    @jacksonfive5180 8 หลายเดือนก่อน

    Fantastic explanation.

  • @phyyl
    @phyyl 2 ปีที่แล้ว

    The V in SIGSEGV stands for Violation

  • @shirleyachara3809
    @shirleyachara3809 4 ปีที่แล้ว

    Great lecture with very useful example codes.

  • @sourashismondal5060
    @sourashismondal5060 ปีที่แล้ว

    Please make a video of how exception handling works internally.

  • @smorrow
    @smorrow 4 ปีที่แล้ว

    7:56 "read works this way basically for performance reasons"
    And reading from the terminal.

  • @patrickmullen2914
    @patrickmullen2914 2 ปีที่แล้ว

    Great video. I learned a lot 👍

  • @CMDRunematti
    @CMDRunematti 5 ปีที่แล้ว +1

    lp starts from 0 because it always would have a printer, but wouldn't necessarily have a storage device (like back in the day when you typed your programs in)

  • @amandafalke7670
    @amandafalke7670 7 ปีที่แล้ว

    Great videos that really complement my Embedded Operating Systems class. Thank you!

  • @cyrilemeka6987
    @cyrilemeka6987 11 หลายเดือนก่อน

    49:58 what of SIGINT?

  • @kamilkowalski776
    @kamilkowalski776 4 ปีที่แล้ว +1

    segv = segmentation violation ?

  • @sasuke2910
    @sasuke2910 9 ปีที่แล้ว +19

    A process can send signals to other that are owned by the same user? Does this mean that typical programs have the ability to kill each other?

    • @briantwill
      @briantwill  9 ปีที่แล้ว +26

      +Jeru Sanders Yes, this is the case. It's one reason why 'important' programs tend to be set up with their own user account.

    • @omkarajagunde4175
      @omkarajagunde4175 4 ปีที่แล้ว +1

      At unix time signal were only sent for killing other processes and not for IPC or any other thing but as time passed developers found signals can be used for other good things for IPC sending interrupts etc .. There is a table like structure in U-area of each process where one column is all the signals supported by OS (19 signals supported in case of UNIX) and 2 second column consists of signal catcher function address passed as parameter by the programmer by calling signal system call in their programs then when a process is switching mode to user mode from kernel mode "isSig" algorithm is executed to see which signals are received by the process and not yet serviced and then to serve these queued signals "psig" algorithm is executed and if a particular signal is not specified with catcher function then default address corresponding to the second column of that signal consists by default 0 address which is exit() system call address and the process is put in Zombie state by the kernel.
      You can see signal macros in

  • @Mr.Nichan
    @Mr.Nichan 2 ปีที่แล้ว

    10:16 Given everything else you said here, it seems like it should have been mentioned what happens when you write when the marker is NOT at the end of a file. I'm guessing you thought it was obvious that you would overwrite the data, like a hard drive, rather than inserting data, as is now the default in modern text files, though it requires changing the addresses of every byte later on in the file. That's sort of implied by the fact that you only say it expands the file if the marker goes past the end of the file. In addition to simply being more complicated, inserting would expand the file no matter where the new data was written in, and would also require separate deleting calls for completion.

  • @berargumen2390
    @berargumen2390 3 ปีที่แล้ว

    I watched this video like 7 years ago, but just know i undesrtand this

  • @WeightlessFlex
    @WeightlessFlex 4 ปีที่แล้ว

    Do you have a Unix networking seriesor know of a good one

  • @iberianful
    @iberianful 6 หลายเดือนก่อน

    Great tutorial.

  • @adityanagesh4922
    @adityanagesh4922 4 ปีที่แล้ว

    Why can't unnamed pipe be used by unrelated processes? When we create a pipe is the r and w permission for the file only given to the real id of the program?

  • @nofmxc
    @nofmxc 2 ปีที่แล้ว

    I know this is old, but are the character device file buffers stored in the operating systems memory space? Or on disk? Or on the device?

    • @davidbekic6569
      @davidbekic6569 2 ปีที่แล้ว

      Been wondering the same thing, t'as trouvé la réponse?

  • @KillYourFinger
    @KillYourFinger 7 ปีที่แล้ว +1

    your videos are a blast man! helped me so much! keep it up please

  • @hacker64xfn99
    @hacker64xfn99 2 ปีที่แล้ว

    I hope u see my comment as this video was not published 11 years ago : How does device drivers actually work in these system calls, are not drivers the ones responsible for managing their devices associated with, as they create their device objects ? In Microsoft Windows, what is the Device object file and is the symbolic link object (found in ObjManager.exe) same as these symbolic links mentioned in this videos ? Also, does the DevDevice file object (at object manager) contain block and character device files equivalent to the dev/ directory in unix-like systems ? Anyways, great content, keep up your work 😊

  • @buihung3704
    @buihung3704 ปีที่แล้ว

    I though ReadWrite is controlled by semaphores? You can have many reads at the same time but only 1 write can occur at any time. How the hell can you have multiple write and multiple read at the same time? Is it a really serious problem if 2 write overwriting each other in the buffer, results in corrupted data?
    Edit: Ah I get it, so the buffer doesn't have coordination by default, it solely relies on the human developers of a specific program (Dev team of MySQL for instance) to control the read and write explicitly using multiple techniques, one of them is using semaphore.

  • @ziaahmad8738
    @ziaahmad8738 7 หลายเดือนก่อน

    Thank you!

  • @haispdn
    @haispdn 12 ปีที่แล้ว +1

    Very useful lecture.. highly recommended

  • @rathnec
    @rathnec 4 ปีที่แล้ว +1

    Thanks Brian.. A doubt on segmentation, I think paging did not make segmentation obsolete, right?.. Page fault and sen fault are two different issues.. Page fault can't be considered as an error.. it just means that the page the process is looking for is not found in the main memory.. Seg fault on the other hand is actually an unauthorized access of memory area which cause the process to terminate.. Is this right!!?

    • @lawrencemanning
      @lawrencemanning 3 ปีที่แล้ว +2

      Pages and segments do the same thing and are a means to isolate address spaces. The V in SIGSEGV is short for violation I believe, and refers to segments because, presumably, the first UNIXes ran on computers that used segments for process isolation. So a context switch would update the various segment registers instead of switching page tables, as happens now.

  • @JosephRawsonWorks
    @JosephRawsonWorks 2 ปีที่แล้ว +1

    I used mkfifo for named pipes

  • @movq7539
    @movq7539 2 ปีที่แล้ว

    really good

  • @fuanka1724
    @fuanka1724 7 ปีที่แล้ว

    Excellent videos!

  • @subee128
    @subee128 ปีที่แล้ว

    Thanks

  • @xieliming
    @xieliming 12 ปีที่แล้ว

    As he said in previous video, it is pseudocode in the styling of Python. The actual code for making these calls is C

  • @carloseduardomarciano1395
    @carloseduardomarciano1395 7 ปีที่แล้ว

    Amazing video, thanks for the lecture!

  • @supa1009
    @supa1009 5 ปีที่แล้ว

    You sir, are a true legend!

  • @Halogrunt1234
    @Halogrunt1234 10 ปีที่แล้ว +13

    I was very entertained by your herp derp and bla bla example of nonatomic file writes.

    • @mcechss
      @mcechss 8 ปีที่แล้ว

      "her blap" lol

  • @shirleyachara3809
    @shirleyachara3809 4 ปีที่แล้ว

    Thanks.

  • @RogueSignal
    @RogueSignal 5 ปีที่แล้ว +2

    lseek might stand for Linear Seek since it goes down the line.

  • @yourfutureself4327
    @yourfutureself4327 ปีที่แล้ว

    💙

  • @m3hdim3hdi
    @m3hdim3hdi 4 ปีที่แล้ว

    I cant thank you enough

  • @LytGamingV1
    @LytGamingV1 13 ปีที่แล้ว

    are all of these examples written in python?

  • @idobenamram3743
    @idobenamram3743 6 ปีที่แล้ว

    so good

  • @rne1223
    @rne1223 13 ปีที่แล้ว +3

    is the website down?

  • @TheTarnonero
    @TheTarnonero 7 ปีที่แล้ว

    good videos ! thanks for a good explanation!

  • @normally96
    @normally96 5 ปีที่แล้ว +1

    thank you.I eager to join your course but I can't access the link in the description. Can you give me another link ?

  • @melvyniandrag
    @melvyniandrag 7 ปีที่แล้ว

    very useful!

  • @luckyboy20021
    @luckyboy20021 6 ปีที่แล้ว

    thank alot

  • @swapnilhitman
    @swapnilhitman 11 ปีที่แล้ว

    Very informative ... Thank you.

  • @DrRChandra
    @DrRChandra 9 ปีที่แล้ว +4

    mmmm.....no, rmdir(2) will not remove a file (you showed "remove a file or directory"); the only object it will remove is a directory. unlink(2) will remove anything except directories to which you have permissions to do so.
    It's also worthy to note a file continues to exist anonymously until there is no longer any process with it open. I used to run into that all the time with a database program which would create some temporary files (for temporary tables), and I needed to free up disk space because the filesystem was full. I could rm(1) them, but the disk would still be full until I shut down the database (and thus its process called close(2) or _exit(2)).

  • @MrFrankSpierings
    @MrFrankSpierings 12 ปีที่แล้ว +8

    sigsegv => segmentation violation ;)

  • @erikbmyname
    @erikbmyname 11 ปีที่แล้ว

    Thanks for these!

  • @coolwinder
    @coolwinder 8 ปีที่แล้ว

    Can i ask one dumb question?
    How do i call e.g. chdir or mkdir...? Where is it, is it some compiled C executable, and if yes, where is it?
    So i am reading chdir man page man7.org/linux/man-pages/man2/fchdir.2.html and it tells me to include some lib , so there are functions?
    So if i want to call functions in C to read and write files i need to use librarys for reading and writing found on that operating system? So what is then, is it standard library that is writen separately for each OS, so when i am writing program in C i dont need to rewrite my program each time i want to compile it for different OS? And lib is calling open system call for function fopen for Linux, in windows it would call something else?
    This isn't realy one question, but my train of thought. Maybe i should put it on reddit (/r/Showerthoughts/) :D. Thanks.

    • @gigiduru125
      @gigiduru125 8 ปีที่แล้ว +2

      In Linux these are in the libc library www.gnu.org/software/libc/manual/html_node/Working-Directory.html#Working-Directory.
      Linux and Windows have different APIs and system calls, fork() in Windows is called CreateProcess(), has different parameters and is part of the Windows (Win32) API en.wikipedia.org/wiki/Windows_API.

    • @omkarajagunde4175
      @omkarajagunde4175 4 ปีที่แล้ว

      @@gigiduru125 Yes as windows believes in thread based processing and at UNIX time their was only legacy Process based processing

    • @omkarajagunde4175
      @omkarajagunde4175 4 ปีที่แล้ว

      mainly chdir() and mkdir() at UNIX period was a system call, also i must tell you that chdir and mkdir are also internal commands of shell(shell have 2 types of commands internal and external), the code for internal commands like."ls" and ''cd" (chdir) is implemented by shell itself so their binary executable is no where separate but their code lies in the binary executable of shell, If a command is external command then it lies in /bin directory. Hope that helps !.. for further reading you may read Maurice J Bach book

  • @krzysztof-ws9og
    @krzysztof-ws9og 4 ปีที่แล้ว

    I have managed to divide by '0' without getting SIGFPE
    I have got +inf as a result

    • @xrafter
      @xrafter 4 ปีที่แล้ว

      '0' is charachter which is 48 in his maping in ascii
      But 0 is 0 not 48

    • @smorrow
      @smorrow 4 ปีที่แล้ว +3

      You didn't cause the actual computer to divide by zero.

  • @amitkrdce
    @amitkrdce 12 ปีที่แล้ว +1

    i guess V in SIGSEGV means System V? but i can be wrong.

  • @harishkumars3209
    @harishkumars3209 12 ปีที่แล้ว

    i'm interested in developing os can u help me