 In this screencast, we would be describing system calls. A system call or syscall is an API that the kernel provides to user programs. What do system calls do? Almost everything. When you hit control S to save a file, you're actually invoking a system call. When your browser is trying to send data over the network, also invoking a system call. Since the kernel does not allow user space programs to access any hardware resource directly, it is always done through system calls. We will now see what a system call looks like. To do so, we first disassemble one of the simplest programs and see what it is doing. In this case, the program we have chosen is a program named Bintrue, whose source code can be found under the following directory. As you can see, Bintrue is really simple and it just invokes one function named exit passing a code of zero. Now let's look at what Bintrue looks like disassembled. To disassemble the program, we first need to navigate to the root directory and the bin directory under root. To disassemble true, we invoke the program os161 obj dump using the dash D flag and pass the program name, which in this case is true. Object dump generates quite a bit of output. This can be seen here. Now given that this is difficult to navigate and search in, we're going to pipe the output of object dump into a file named true.s. Now opening up true.s in the editor of your choice, we quickly jump to main function and find the call to exit, which can be found here. Now given that exit is a function, let's quickly look at what exit is doing. Exit in turn immediately jumps to another function named underscore exit, which is also found in this file. And as you can see underscore exit jumps to another function named underscore underscore syscall. Now let's look at this a little more closely. Although the li instruction lies below the jump, it lies in a special place known as the jump delay slot, which ends up executing before the jump itself. So for all practical purposes, you can assume that the order of instruction execution is like this. Now, given that we are jumping to a function named underscore underscore syscall, which is also found here, it raises the question as to where the content of this syscall function came from. To find this out, we're going to open a new terminal and search for underscore underscore syscall. There are two results to this. One is in the build directory or the compiled output and the other is the source. We're going to open up the syscalls.s file, which is in the build directory. We can quickly find the syscall function here, which contains quite a few instructions in assembly and each of these instructions have comments. So clearly the first line of underscore underscore syscall is syscall, which is an instruction that invokes a software interrupt in the kernel. Now, because this is invoking a software interrupt, we cannot execute this line until the kernel has finished servicing the interrupt. And as we can see from the comments, clearly once the interrupt is triggered, the kernel services it and then we check the return code after the kernel has serviced our interrupt. If it is zero, then the call succeeded, as the comments say. However, if it fails, then we store the error code into this global variable inside libc called erno and then we return minus one to the calling function. This is how the system call works in user space. In the next screencast, we will describe how the system call looks like to the kernel.