Hello and welcome to this session.
In this session we will discuss the concepts of system calls.
A system call can be considered as an interface through which a user application code can enter the
kernel mode.
Hence the system runs in kernel mode on behalf of the user program during the system.
Call execution.
The system call can be invoked from user application in two ways.
In first method, the user program can call the system called directly.
In second method, the user program can call a library function, and this library function can invoke
corresponding system call when required.
The examples of system calls are open system call, write, close, read system call, and there are
many more system calls.
As discussed earlier, the system call can be invoked through library functions.
For example, printf is a library function and the printf can call the write system call internally.
Now let's see the demo of system call.
In this program, we use the system call write directly to display the string onto the screen.
Earlier, we had done the same using library function like printf.
The write system call takes first parameter, which specifies the destination of the string.
Here we use '1'.
'1' represents standard output, which is the screen.
We will learn more on this on later videos.
As a note, '0' refers to standard input that is the keyboard.
'1' refers to standard output, which is the screen in this case, and '2' refers to standard error.
Now let us compile this code using GCC.
The command used to compile code is GCC, followed by the name of the C code -o.
And finally, we specify the output file name.
Now.
We have compiled the code and the output file named sys_ex is generated.
Now let us execute the output file.
After running the output file, we can see the string printed to the screen.
Here we have demonstrated that the write system call.
The write system call without the printf, which is a library function.
In next session.
Let us discuss more on system calls.
Thank you.